def select_target(self, targets):
     allies = targets['ally']
     UI().show_text("Select your target:")
     UI().list_targets(allies)
     index = UserInput().select_index_from_options(allies)
     # always return an array!!!
     return [allies[index]]
Esempio n. 2
0
    def fight(self):
        win = False
        lose = False
        while not win | lose:
            UI().show_text("New Round!")
            self.print_battlefield()

            targets = {
                'ally': self.party.get_actionable_members(),
                'enemy': self.monsters.get_actionable_members()
            }

            actions = BattleMenu(targets).begin_menu_selection()
            actions.extend(self.get_random_monster_actions())

            actions = self.sort_actions_by_priority(actions)
            new_round = Round(actions)
            new_round.process_round_actions()

            if len(self.party.get_actionable_members()) == 0:
                lose = True
            elif len(self.monsters.get_actionable_members()) == 0:
                win = True

            UI().show_text("\n\n")
        if win:
            UI().show_text("You've won the battle!!")
        elif lose:
            UI().show_text("You've lost the battle...")
Esempio n. 3
0
def main():
    BorrowRepo = BorrowRepository("borrow.txt")
    DvdRepo = DvdRepository("dvd.txt")
    
    ctrl = Controller(BorrowRepo,DvdRepo) 
    ui = UI(ctrl)
    ui.run()
Esempio n. 4
0
 def receive_battle_effect(self, battle_effect):
     if battle_effect.effect_type == EffectType.physical:
         damage = battle_effect.calculate_power() - self.defense
         if damage > 0:
             UI().show_text("\t" + self.name + " takes " + str(damage) +
                            " damage!!!")
             self.current_hp -= damage
             self.faint()
         # TODO: apply physical strategy
     elif battle_effect.effect_type == EffectType.magical:
         damage = battle_effect.calculate_power(
         )  # TODO:  magical damage?  Resistance?
         if damage > 0:
             UI().show_text("\t" + self.name + " takes " + str(damage) +
                            " magical damage!!!")
             self.current_hp -= damage
         return
     elif battle_effect.effect_type == EffectType.healing:
         healing = battle_effect.calculate_power()
         if healing > 0:
             UI().show_text("\t" + self.name + " recovers " + str(healing) +
                            " HP!")
             self.current_hp += healing
             if self.current_hp > self.max_hp:
                 self.current_hp = self.max_hp
     return
Esempio n. 5
0
def start():
    settings = Settings.getInstance()
    Constants.ROW_COUNT = int(settings.DIM)
    Constants.COLUMN_COUNT = int(settings.DIM)
    Constants.APPLE_COUNT = int(settings.apple_count)

    player = Player()
    gameService = GameService(player)
    ui = UI(gameService)
    ui.run()
Esempio n. 6
0
 def select_index_from_options(self, options):
     while True:
         selection = input("Choose a selection:  ")
         if selection.isdigit():
             selection = int(selection)
             if self.__within_bounds(selection, options):
                 # We're not zero indexing these,
                 return selection - 1
         else:
             UI().show_text("Input must be numeric!")
Esempio n. 7
0
 def generate_round_actions(self):
     if len(self.fighter.spells) > 0:
         UI().show_options(self.fighter.spells)
         index = UserInput().select_index_from_options(self.fighter.spells)
         action = self.fighter.spells[index]
         target = action.selection_strategy.select_target(
             self.targets)  # get selection strategy from action!
         return RoundAction(action, target)
     else:
         print("no spells.")  # this should never appear.
    def __init__(self, controllerWrapper: ControllerWrapper):
        UI.__init__(self, controllerWrapper)
        self.frame1 = None
        self.frame2 = None
        self.frame3 = None
        self.frame4 = None
        self.frame5 = None
        self.frame6 = None
        self.frame7 = None
        self.studentId = None
        self.studentName = None
        self.studentGroup = None
        self.assignmentId = None
        self.assignmentDescription = None
        self.assignmentDeadline = None
        self.grade = None
        self.studentController = controllerWrapper.getStudentController()
        self.gradeController = controllerWrapper.getGradeController()
        self.assignmentController = controllerWrapper.getAssignmentController()

        self.__window = self.buildWindow()
Esempio n. 9
0
    def begin_menu_selection(self):
        round_actions = []
        for fighter in self.targets['ally']:
            UI().show_text(fighter.name + "'s turn!")
            # TODO:  Get the round options from the Fighter themselves.
            '''battle_options = [AttackOption(fighter, self.targets),
                              MagicOption(fighter, self.targets),
                              RunOption(fighter, None)]'''
            battle_options = self.get_options_for_fighter(fighter)
            self.show_options(battle_options)
            selected_actions = self.select_action(battle_options)
            # generate the action from battle effects and an array of selected targets, and add them the the queue

            round_actions.append(selected_actions)

        return round_actions
Esempio n. 10
0
 def show_options(self, battle_options):
     for count, option in enumerate(battle_options, start=1):
         UI().show_text(str(count) + ") " + option.name)
Esempio n. 11
0
    parser = Parser()
    querys = []
    querys.append(
        "SELECT [ ENAME = 'Mary' & DNAME = 'Research' ] ( EMPLOYEE JOIN DEPARTMENT )"
    )
    querys.append(
        "PROJECTION [ BDATE ] ( SELECT [ ENAME = 'John' & DNAME = 'Research' ] ( EMPLOYEE JOIN DEPARTMENT ) )"
    )
    querys.append(
        "SELECT [ ESSN = '01' ] ( PROJECTION [ ESSN , PNAME ] ( WORKS_ON JOIN PROJECT ) )"
    )
    querys.append(
        "PROJECTION [ ENAME ] ( SELECT [ SALARY < 3000 ] ( EMPLOYEE JOIN SELECT [ PNO = 'P1' ] ( WORKS_ON JOIN PROJECT ) ) )"
    )
    querys.append(
        "PROJECTION [ DNAME , SALARY ] ( AVG [ SALARY ] ( SELECT [ DNAME = 'Research' ] ( EMPLOYEE JOIN DEPARTMENT ) ) )"
    )
    # parser.run(querys[0])
    # print('productions :')
    # for pro in parser.cfg.productions:
    #     print(str(pro))

    # 多条测试
    ui = []
    for i in querys:
        ui.append(UI(Parser(), i))
        ui[-1].root()
    # 单条测试
    # i = 4
    # ui = UI(Parser(),querys[i])
    # ui.root()
Esempio n. 12
0
from Library import Library
from ui.UI import UI

if __name__ == '__main__':
    system = Library(host="localhost", user="******", pwd="MySQL")
    our_ui = UI(system)
Esempio n. 13
0
'''
Created on Jan 23, 2017

@author: Madalina
'''
from repository.Repository import Repository
from controller.Controller import Controller
from ui.UI import UI

repo = Repository()
controller = Controller(repo)
ui = UI(controller)

ui.mainMenu()
Esempio n. 14
0
 def get_indent(self, row):
     UI().show_line(" " * 11 * (self.MAX_ROW_SIZE - len(row)))
Esempio n. 15
0
 def print_party_names(self, row):
     self.get_indent(row)
     for member in row:
         UI().show_line("|{:^20}|".format(member.name))
     UI().show_text("")
Esempio n. 16
0
from ui.UI import UI

app = UI()

app.run()
# cmd = input("Please insert command: ").split()
# print(cmd)
'''
Created on 30 dec. 2017

@author: Catalin
'''

from domain.components import board
from op.controller import controller
from ui.UI import UI
from utilities import readBoardSize

x,y=readBoardSize()
b=board(y,x)
ctr=controller(b)
ui=UI(ctr)

ui.main()
Esempio n. 18
0
from repository.RepositoryCarte import RepositoryCarte
from repository.RepositoryPersoana import RepositoryPersoana
from controller.Controller import Controller
from ui.UI import UI

repoCarte = RepositoryCarte("carti.txt")
repoPersoana = RepositoryPersoana("persoane.txt")
ctr = Controller(repoCarte, repoPersoana)
ui = UI(ctr)
ui.run()
Esempio n. 19
0
 def __within_bounds(self, index, options):
     if index - 1 in range(0, len(options)):
         return True
     else:
         UI().show_text("Pick a valid option!")
         return False
Esempio n. 20
0
from domain.DoubleDirectedGraph import Graph
from Repository.Repository import Repository
from controller.Controller import Controller
from ui.UI import UI
file = open("data.txt","r")
nr_of_vertices = file.readline()
nr_of_vertices = nr_of_vertices.split(" ")
file.close()
#newLine = file.readline()
#newLine = newLine.split(" ")

graph = Graph(int(nr_of_vertices[0]))
repo = Repository(graph)
repo.loadFromFile()
controller = Controller(repo)
ui = UI(controller)
ui.mainLoop()

#DO NOT REMOVE VERTICES THEY ALWAYS COME BACK LOL
Esempio n. 21
0
 def print_horizontal_bar(self, row):
     self.get_indent(row)
     for member in row:
         UI().show_line("-" * 22)
     UI().show_text("")
'''
Created on 3 feb. 2018

@author: Catalin
'''
from domain.components import board
from controller.controller import controller
from ui.UI import UI
from gamefile import boardfile

b=board() #initialize a board
c=controller(b) #initialize a controller
u=UI(c) #initialize the user interface

u.main() #run the program
Esempio n. 23
0
 def print_party_hp(self, row):
     self.get_indent(row)
     for member in row:
         UI().show_line("|{:<20}|".format("HP: " + str(member.current_hp) +
                                          "/" + str(member.max_hp)))
     UI().show_text("")
Esempio n. 24
0
from ui.UI import UI

ui = UI()
ui.show_ui()
Esempio n. 25
0
from controller.bigboss import Boss
from controller.controller import PlayerController
from domain.entities import Board
from ui.UI import UI

player_planes = Board()
player_hits = Board()
player = PlayerController(player_planes, player_hits)
computer_planes = Board()
computer_hits = Board()
computer = PlayerController(computer_planes, computer_hits)
controller = Boss(player, computer)
ui = UI(controller)
ui.run()
# player.new_plane(Point("E", 4, "W"))
# player.new_plane(Point("A", 3, "N"))
Esempio n. 26
0
 def faint(self):
     if self.current_hp <= 0:
         self.current_hp = 0
         UI().show_text("\t" + self.name + " has fainted!")
Esempio n. 27
0
 def process_round_actions(self):
     for action in self.round_actions:
         if action.targets is None:
             UI().show_text(action.battle_effect.get_battle_text())
         elif action.battle_effect.source_fighter.current_hp > 0:
             action.apply_battle_effect()
Esempio n. 28
0
 def print_field(self):
     UI().show_text("\n\n\n")
Esempio n. 29
0
from repo.LinkRepo import LinkRepo
from ui.UI import UI


class AppStart():
    '''
    Starts application
    '''
    def __init__(self, ui):
        self._ui = ui

    def call(self):
        self._ui.loop()


srepo = StudentRepo()
arepo = AssignRepo()
lrepo = LinkRepo()
linkid = 0
ashandler = AssignHandler(arepo)
sthandler = StudHandler(srepo)
linkhandler = LinkHandler(arepo, srepo, lrepo, linkid)
ui = UI(ashandler, sthandler, linkhandler)
appstart = AppStart(ui)
ui._sthandler._studrepo.readfromfile()
ui._ashandler._assignrepo.readfromfile()
for counter in ui._sthandler._studrepo._data:
    newassign = ui._ashandler._assignrepo.findById(counter.getID())
    ui._linkhandler.makeLink(newassign, counter)
appstart.call()
Esempio n. 30
0
'''
Created on Mar 14, 2017

@author: Denis
'''

from domain.Graph import DoubleDictGraph, Edge_property
from ui.UI import UI

edgePr = Edge_property()
my_graph = DoubleDictGraph(
    r"C:\Users\Denis\Desktop\GitHub\College\Algoritmica Grafelor\Lab01\graph1k.txt",
    edgePr)
ui = UI(my_graph)
ui.mainMenu()