コード例 #1
0
ファイル: Battle.py プロジェクト: falchek/PythonRPG
    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...")
コード例 #2
0
 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]]
コード例 #3
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
コード例 #4
0
def main():
    BorrowRepo = BorrowRepository("borrow.txt")
    DvdRepo = DvdRepository("dvd.txt")
    
    ctrl = Controller(BorrowRepo,DvdRepo) 
    ui = UI(ctrl)
    ui.run()
コード例 #5
0
ファイル: UserInput.py プロジェクト: falchek/PythonRPG
 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!")
コード例 #6
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.
コード例 #7
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()
コード例 #8
0
ファイル: BattleMenu.py プロジェクト: falchek/PythonRPG
    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
コード例 #9
0
ファイル: PartyRender.py プロジェクト: falchek/PythonRPG
 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("")
コード例 #10
0
ファイル: PartyRender.py プロジェクト: falchek/PythonRPG
 def print_party_names(self, row):
     self.get_indent(row)
     for member in row:
         UI().show_line("|{:^20}|".format(member.name))
     UI().show_text("")
コード例 #11
0
ファイル: PartyRender.py プロジェクト: falchek/PythonRPG
 def print_horizontal_bar(self, row):
     self.get_indent(row)
     for member in row:
         UI().show_line("-" * 22)
     UI().show_text("")
コード例 #12
0
ファイル: BattleMenu.py プロジェクト: falchek/PythonRPG
 def show_options(self, battle_options):
     for count, option in enumerate(battle_options, start=1):
         UI().show_text(str(count) + ") " + option.name)
コード例 #13
0
ファイル: UserInput.py プロジェクト: falchek/PythonRPG
 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
コード例 #14
0
'''
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
コード例 #15
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()
コード例 #16
0
ファイル: Round.py プロジェクト: falchek/PythonRPG
 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()
コード例 #17
0
from ui.UI import UI

app = UI()

app.run()
# cmd = input("Please insert command: ").split()
# print(cmd)
コード例 #18
0
'''
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()
コード例 #19
0
ファイル: Battle.py プロジェクト: falchek/PythonRPG
 def print_field(self):
     UI().show_text("\n\n\n")
コード例 #20
0
ファイル: PartyRender.py プロジェクト: falchek/PythonRPG
 def get_indent(self, row):
     UI().show_line(" " * 11 * (self.MAX_ROW_SIZE - len(row)))
コード例 #21
0
ファイル: main.py プロジェクト: GeorgianBadita/Projects
from ui.UI import UI

ui = UI()
ui.show_ui()
コード例 #22
0
ファイル: main.py プロジェクト: yudi6/LibraryManagementSystem
from Library import Library
from ui.UI import UI

if __name__ == '__main__':
    system = Library(host="localhost", user="******", pwd="MySQL")
    our_ui = UI(system)
コード例 #23
0
 def faint(self):
     if self.current_hp <= 0:
         self.current_hp = 0
         UI().show_text("\t" + self.name + " has fainted!")
コード例 #24
0
ファイル: test.py プロジェクト: 1170301027/queryOptimization
    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()
コード例 #25
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()
コード例 #26
0
ファイル: startApp.py プロジェクト: denisvieriu/College
'''
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()