def resume_game_state(self): rog.game_set_state(self._resume_game_state) # #-------------------# # specific managers # #-------------------# # # Action Queue # class Manager_ActionQueue(Manager):
def main(): #------------------------------------------------# # INIT #------------------------------------------------# # new way to init rog.Rogue.create_settings() # later controllers might depend on settings rog.Rogue.create_window() rog.Rogue.create_consoles() rog.Rogue.create_world() rog.Rogue.create_controller() rog.Rogue.create_data() rog.Rogue.create_map() rog.Rogue.create_clock() rog.Rogue.create_updater() rog.Rogue.create_view() rog.Rogue.create_log() rog.Rogue.create_savedGame() rog.Rogue.create_processors() rog.Rogue.create_perturn_managers() rog.Rogue.create_const_managers() rog.Rogue.create_player(0,0) # what position should be given? rog.init_keyBindings() ## #map generation ## rog.map_generate(rog.map(),rog.dlvl()) ## ## # init player object ## pc=rog.create_player(15,15) ## # TODO: observer for player #### obs=observer.Observer_playerChange() #### pc.observer_add(obs) ## rog.view_center(pc) ## ## ## ##TESTING ## rog.gain(pc,"hpmax",100) ## log=rog.create_stuff(THG.LOG, 18,18) ## rog.burn(log,200) ## box=rog.create_stuff(THG.BOX,20,18) ## #fluids.smoke(16,16) ## '''pc.stats.hpmax = 20 ## pc.stats.mpmax = 20 ## pc.stats.sight = 20 ## pc.stats.spd = 100 ## pc.stats.nvision = False''' ## #LIGHT ## pc.light=rog.create_light(pc.x,pc.y, 5, owner=pc) ## #HEAL ## rog.givehp(pc) ## rog.givemp(pc) ## #EQUIP ## #print(pc.stats.get('atk')) ## item=gear.create_weapon("sword",pc.x,pc.y) ## rog.equip(pc, item, EQ_MAINHAND) ## #print(pc.stats.get('atk')) ## #rog.deequip(pc,EQ_MAINHAND) ## #print(pc.stats.get('atk')) ## #BUFF ## #rog.effect_add(pc,{'atk':5}) ## #rog.effect_add(pc,{'dmg':5}) ## #rog.effect_add(pc,{'arm':0}) ## #rog.effect_add(pc,{'msp':15}) ## #rog.effect_add(pc,{'msp':-50})''' ## ''' ## z = rog.create_monster('Z',15,16) ## rog.effect_add(z,{'arm':1}) ## rog.effect_add(z,{'dfn':4}) ## rog.effect_add(z,{'atk':3}) ## rog.effect_add(z,{'dmg':3}) ## rog.givehp(z)''' ## z=rog.create_monster('z',13,19,COL['ltblue']) ## a=rog.create_monster('a',12,13,COL['scarlet']) ## o=rog.create_monster('U',19,18,COL['red']) ## a=rog.create_monster('a',15,17,COL['scarlet']) ## W=rog.create_monster('W',20,15,COL['purple']) ## '''import dice ## for x in range(ROOMW): ## for y in range(ROOMH): ## if dice.roll(100) > 98: ## if not (rog.wallat(x,y) ## or rog.monat(x,y) ): ## r=rog.create_monster('r',x,y) ## r.color=COL['ltgray'] ## print("num monsters: ", len(rog.list_creatures())) ## ''' #-----------------------------------------------# # # MAIN GAME LOOP # # #-----------------------------------------------# rog.game_set_state("normal") ## # initialize fov for creatures with sight ## # IS THIS NOT WORKING???? WHAT'S GOING ON? ## for creat in rog.list_creatures(): ## if creat.stats.sight > 0: ## rog.fov_compute(creat) while rog.game_is_running(): # manually close game # if libtcod.console_is_window_closed(): rog.end() # defeat conditions # if rog.on(pc, DEAD): rog.game_set_state("game over") # get input # pcInput=IO.get_raw_input() pcAct=IO.handle_mousekeys(pcInput).items() # commands that are available from anywhere # player.commands_const(pc, pcAct) # Finally record game state after any/all changes # gameState=rog.game_state() #----------# # PLAY # #----------# # # normal game play # if gameState == "normal": game.play(pc, pcAct) # # other game states # # elif (gameState == "move view" or gameState == "look" or gameState == "busy" or gameState == "message history" ): manager=rog.get_active_manager() manager.run(pcAct) if manager.result: rog.close_active_manager() # elif gameState == "game over": rog.msg("You died...")
def resume_game_state(self): rog.game_set_state(self._resume_game_state)
def main(): #------------------------------------------------# # INIT #------------------------------------------------# rog.Rogue.create_settings() # later controllers may depend on settings rog.Rogue.create_window() rog.Rogue.create_consoles() rog.Rogue.create_world() rog.Rogue.create_controller() rog.Rogue.create_data() rog.Rogue.create_map(ROOMW, ROOMH) ## rog.Rogue.create_fov_maps() rog.Rogue.create_clock() rog.Rogue.create_updater() rog.Rogue.create_view() rog.Rogue.create_log() rog.Rogue.create_savedGame() # TODO: learn/use Pickle. rog.Rogue.create_processors() rog.Rogue.create_perturn_managers() rog.Rogue.create_const_managers() rog.Rogue.create_const_entities() rog.init_keyBindings() #map generation rog.getmap(rog.dlvl()).init_specialGrids( ) # inits fov_map; do this before you init terrain rog.getmap(rog.dlvl()).init_terrain(WALL) # clear the map to all walls rog.getmap(rog.dlvl()).generate_dlvl(rog.dlvl()) # init player # TESTING THIS IS ALL TEMPORARY!!! # temporary: find a position to place the player xpos = 15 ypos = 15 _borders = 10 while rog.getmap(rog.dlvl()).tileat(xpos, ypos) == WALL: xpos += 1 if xpos >= ROOMW - _borders: xpos = _borders ypos += 1 if ypos >= ROOMH: print("~~ ! FATAL ERROR ! Failed to place player in the map!") break rog.Rogue.create_player(xpos, ypos) # create player pc = rog.pc() # TESTING # HELP THE PLAYER TO SEE rog.create_envlight(16) ## rog.make(rog.pc(), NVISION) # w = rog.create_monster('W', xpos, ypos - 1) ## rog.world().add_component(w, cmp.AttractedToMen()) ## rog.world().add_component(w, cmp.AttractedToWomen()) ## ## #testing speech ## rog.init_person(w) # ## w2=rog.create_monster('W',xpos,ypos+1) ## w3=rog.create_monster('W',xpos,ypos+2) ## rog.setskill(pc, SKL_BOXING, 100) ## rog.setskill(pc, SKL_PERSUASION, 0) ## rog.setskill(pc, SKL_ARMOR, 100) ## rog.sets(pc, 'dex', 12*MULT_STATS) ## rog.sets(pc, 'int', 4*MULT_STATS) ## rog.setskill(pc, SKL_UNARMORED, 40) ## for x in range(20): ## rog.create_monster("L", 1+x*5,1) ## rog.alts(pc, 'sight', 50) weap = rog.create_weapon("sword", xpos, ypos, mat=MAT_METAL) weap = rog.create_weapon("buckler", xpos, ypos, mat=MAT_METAL) ## ## rog.wound(pc, WOUND_BURN, 2) ## rog.damage(weap, 200) ## rog.fitgear(weap, pc) ## print(rog.equip( ## pc,weap,EQ_MAINHANDW ## )) ## rog.create_weapon("wooden club", xpos,ypos) ## rog.create_weapon("estoc", xpos-1,ypos) ## shield=rog.create_weapon("metal shield", 0,0) ## rog.equip( ## pc,shield,EQ_OFFHAND ## ) ## rog.fitgear(shield, pc) ## armor=rog.create_armor("metal gear", 0,0) ## rog.equip( ## pc,armor,EQ_FRONT ## ) ## rog.fitgear(armor, pc) ## helm=rog.create_headwear("metal helm", 0,0) ## rog.equip( ## pc,helm,EQ_MAINHEAD ## ) ## rog.fitgear(helm, pc) ## leg1=rog.create_legwear("metal mail legging", 0,0) ## rog.equip( ## pc,leg1,EQ_MAINLEG ## ) ## rog.fitgear(leg1, pc) ## leg2=rog.create_legwear("metal mail legging", 0,0) ## rog.equip( ## pc,leg2,EQ_OFFLEG ## ) ## rog.fitgear(leg2, pc) ## arm1=rog.create_armwear("metal vambrace", 0,0) ## rog.equip( ## pc,arm1,EQ_MAINARM ## ) ## rog.fitgear(arm1, pc) ## arm2=rog.create_armwear("metal vambrace", 0,0) ## rog.equip( ## pc,arm2,EQ_OFFARM ## ) ## rog.fitgear(arm2, pc) ## foot1=rog.create_footwear("metal boot", 0,0) ## rog.equip( ## pc,foot1,EQ_MAINFOOT ## ) ## rog.fitgear(foot1, pc) ## foot2=rog.create_footwear("metal boot", 0,0) ## rog.equip( ## pc,foot2,EQ_OFFFOOT ## ) ## rog.fitgear(foot2, pc) # # create light so player can see ## log=rog.create_rawmat("log", 18,18) ## rog.burn(log,500) # # /TESTING /TEMPORARY # # TODO?: observer for player ## obs=observer.Observer_playerChange() ## pc.observer_add(obs) #-----------------------------------------------# # # MAIN GAME LOOP # # #-----------------------------------------------# rog.game_set_state("normal") while rog.game_is_running(): # manually close game # if libtcod.console_is_window_closed(): rog.end() # defeat conditions # if rog.on(rog.pc(), DEAD): rog.game_set_state("game over") # get input # pcInput = IO.get_raw_input() pcAct = IO.handle_mousekeys(pcInput).items() # commands that are available from anywhere # player.commands_const(rog.pc(), pcAct) # Finally record game state after any/all changes # gameState = rog.game_state() #----------# # PLAY # #----------# # # normal game play # if gameState == "normal": game.play(pc, pcAct) # # manager game states # # elif gameState == "manager": manager = rog.get_active_manager() manager.run(pcAct) if manager.result: rog.close_active_manager() # elif gameState == "game over": rog.msg("You died...")
def main(): #------------------------------------------------# # INIT #------------------------------------------------# # init settings settings = rog.init_settings() rog.init_keyBindings() # init global controllers rog.create_window(settings.window_width, settings.window_height) rog.create_consoles() rog.create_map() rog.create_data() rog.create_view() rog.create_clock() rog.create_log() rog.create_update() rog.create_environment() rog.create_controller() rog.create_savedGame() # init managers rog.create_const_managers() rog.create_perturn_managers() #map generation rog.map_generate(rog.map(), rog.dlvl()) # init player object pc = rog.create_player(15, 15) obs = observer.Observer_playerChange() pc.observer_add(obs) rog.view_center(pc) ##TESTING rog.gain(pc, "hpmax", 100) log = rog.create_stuff(THG.LOG, 18, 18) rog.burn(log, 200) box = rog.create_stuff(THG.BOX, 20, 18) #fluids.smoke(16,16) '''pc.stats.hpmax = 20 pc.stats.mpmax = 20 pc.stats.sight = 20 pc.stats.spd = 100 pc.stats.nvision = False''' #LIGHT pc.light = rog.create_light(pc.x, pc.y, 5, owner=pc) #HEAL rog.givehp(pc) rog.givemp(pc) #EQUIP #print(pc.stats.get('atk')) #item=gear.create_weapon("sword",pc.x,pc.y) #rog.equip(pc, item, EQ_MAINHAND) #print(pc.stats.get('atk')) #rog.deequip(pc,EQ_MAINHAND) #print(pc.stats.get('atk')) #BUFF #rog.effect_add(pc,{'atk':5}) #rog.effect_add(pc,{'dmg':5}) #rog.effect_add(pc,{'arm':0}) #rog.effect_add(pc,{'msp':15}) #rog.effect_add(pc,{'msp':-50})''' ''' z = rog.create_monster('Z',15,16) rog.effect_add(z,{'arm':1}) rog.effect_add(z,{'dfn':4}) rog.effect_add(z,{'atk':3}) rog.effect_add(z,{'dmg':3}) rog.givehp(z)''' z = rog.create_monster('z', 13, 19, COL['ltblue']) a = rog.create_monster('a', 12, 13, COL['scarlet']) o = rog.create_monster('U', 19, 18, COL['red']) a = rog.create_monster('a', 15, 17, COL['scarlet']) W = rog.create_monster('W', 20, 15, COL['purple']) '''import dice for x in range(ROOMW): for y in range(ROOMH): if dice.roll(100) > 98: if not (rog.wallat(x,y) or rog.monat(x,y) ): r=rog.create_monster('r',x,y) r.color=COL['ltgray'] print("num monsters: ", len(rog.list_creatures())) ''' #create a create_thing function for specific items. #make list of items, etc. yyy = Thing() yyy.x = 16 yyy.y = 13 yyy.mask = '4' yyy.name = 'the four of destiny' yyy.color = COL['gold'] rog.register_inanimate(yyy) ## yyy = Thing() yyy.x = 17 yyy.y = 13 yyy.mask = '*' yyy.name = 'blood clot' yyy.color = COL['dkmagenta'] rog.register_inanimate(yyy) ## ''' yyy=Thing() yyy.name="wood" yyy.mask=chr(15) yyy.material=MAT_WOOD yyy.x=20 yyy.y=12 yyy.mass=20 yyy.stats.hp=1250 yyy.color=COL['brown'] rog.register_inanimate(yyy) rog.set_status(yyy, FIRE) yyy=Thing() yyy.name="wood" yyy.mask=chr(15) yyy.material=MAT_WOOD yyy.x=10 yyy.y=19 yyy.mass=12 yyy.stats.hp=400 yyy.color=COL['brown'] rog.register_inanimate(yyy) rog.set_status(yyy, FIRE)''' ''' yyy=rog.create_light(25,25, 15) yyy=rog.create_light(14,11, 7)''' #-----------------------------------------------# # # MAIN GAME LOOP # # #-----------------------------------------------# rog.game_set_state("normal") # initialize fov for creatures with sight for creat in rog.list_creatures(): if creat.stats.sight > 0: rog.fov_compute(creat) while rog.game_is_running(): # manually close game # if libtcod.console_is_window_closed(): rog.end() # defeat conditions # if rog.on(pc, DEAD): rog.game_set_state("game over") # get input # pcInput = IO.get_raw_input() pcAct = IO.handle_mousekeys(pcInput).items() # commands that are available from anywhere # player.commands_const(pc, pcAct) # Finally record game state after any/all changes # gameState = rog.game_state() #----------# # PLAY # #----------# # # normal game play # if gameState == "normal": game.play(pc, pcAct) # # other game states # # elif (gameState == "move view" or gameState == "look" or gameState == "busy" or gameState == "message history"): manager = rog.get_active_manager() manager.run(pcAct) if manager.result: rog.close_active_manager() # elif gameState == "game over": rog.msg("You died...")