示例#1
0
    def discard_spell( self, explo ):
        ''' Removes spell/technique from pc from menu choice '''
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=self.charsheets[ self.pc ], screen=explo.screen, predraw=explo.view, caption="Discard Known Spell" )

        while keep_going:
            mymenu = charsheet.RightMenu( explo.screen, predraw = myredraw )
            for s in self.pc.techniques:
                if isinstance( s, spells.Spell ):
                    mymenu.add_item( str( s ), s )
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item( "Exit", False )
            myredraw.menu = mymenu
            mymenu.quick_keys[ pygame.K_LEFT ] = -1
            mymenu.quick_keys[ pygame.K_RIGHT ] = 1

            it = mymenu.query()
            if it == -1:
                n = ( explo.camp.party.index(self.pc) + len( explo.camp.party ) - 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it == 1:
                n = ( explo.camp.party.index(self.pc) + 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it:
                # A spell was selected. Deal with it.
                self.pc.techniques.remove( it )
            else:
                keep_going = False
示例#2
0
    def enter_shop( self, explo ):
        '''Find out what the PC wants to do.'''
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=self.charsheets[self.pc], screen=explo.screen, predraw=explo.view, caption=self.caption )

        mymenu = charsheet.RightMenu( explo.screen, predraw = myredraw )
        mymenu.add_item( "Buy Items", self.buy_items )
        mymenu.add_item( "Sell Items", self.sell_items )
        mymenu.add_item( "Identify Items", self.identify_items )
        mymenu.add_item( "Exit", False )
        mymenu.add_alpha_keys()
        myredraw.menu = mymenu
        mymenu.quick_keys[ pygame.K_LEFT ] = -1
        mymenu.quick_keys[ pygame.K_RIGHT ] = 1

        while keep_going:
            it = mymenu.query()
            if it == -1:
                n = ( explo.camp.party.index(self.pc) + len( explo.camp.party ) - 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it == 1:
                n = ( explo.camp.party.index(self.pc) + 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it:
                # A method was selected. Deal with it.
                it( explo )
                myredraw.csheet = self.charsheets[self.pc]
            else:
                keep_going = False
示例#3
0
    def learn_spell( self, explo ):
        ''' Learn spell chosen from menu, adds that spell to your pcs techniques'''
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=self.charsheets[ self.pc ], screen=explo.screen, predraw=explo.view, caption="Learn New Spell" )

        sl = self.spell_list or explo.camp.known_spells

        while keep_going:
            mymenu = charsheet.RightMenu( explo.screen, predraw = myredraw )

            for s in sl:
                if s.can_be_learned( self.pc ) and not any( s.name == t.name for t in self.pc.techniques ):
                    mymenu.add_item( str( s ), s )
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item( "Exit", False )
            myredraw.menu = mymenu
            mymenu.quick_keys[ pygame.K_LEFT ] = -1
            mymenu.quick_keys[ pygame.K_RIGHT ] = 1

            it = mymenu.query()
            if it == -1:
                n = ( explo.camp.party.index(self.pc) + len( explo.camp.party ) - 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it == 1:
                n = ( explo.camp.party.index(self.pc) + 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it:
                # A spell was selected. Deal with it.
                self.pc.techniques.append( it )
            else:
                keep_going = False
示例#4
0
    def browse_spells( self, explo ):
        '''Browse shops spells'''
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=self.charsheets[ self.pc ], screen=explo.screen, predraw=explo.view, caption="Browse Library" )

        while keep_going:
            mymenu = charsheet.RightMenu( explo.screen, predraw = myredraw )
            for s in explo.camp.known_spells:
                mymenu.add_item( str( s ), s )
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item( "Exit", False )
            myredraw.menu = mymenu
            mymenu.quick_keys[ pygame.K_LEFT ] = -1
            mymenu.quick_keys[ pygame.K_RIGHT ] = 1

            it = mymenu.query()
            if it == -1:
                n = ( explo.camp.party.index(self.pc) + len( explo.camp.party ) - 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it == 1:
                n = ( explo.camp.party.index(self.pc) + 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            else:
                keep_going = False
示例#5
0
    def __call__(self, explo):
        pc = explo.camp.party_spokesperson()
        myredraw = charsheet.CharacterViewRedrawer(
            csheet=charsheet.CharacterSheet(pc,
                                            screen=explo.screen,
                                            camp=explo.camp),
            screen=explo.screen,
            predraw=explo.view,
            caption=self.caption)

        rpm = charsheet.RightMenu(explo.screen, predraw=myredraw)
        mydesc = "It will cost {0}gp to stay the night.".format(
            self.cost_per_night)
        rpm.add_item("Stay the night.", True, mydesc)
        rpm.add_item("Not right now.", False, mydesc)
        rpm.add_alpha_keys()

        stay = rpm.query()

        if stay:
            if explo.camp.gold >= self.cost_per_night:
                explo.camp.gold -= self.cost_per_night
                explo.camp.rest()
                explo.alert(
                    "You rest the night and wake up perfectly refreshed.")
            else:
                explo.alert(
                    "You can't afford to stay here! Come back when you've earned some money."
                )
 def do_level_training( self, student ):
     myredraw = charsheet.CharacterViewRedrawer( csheet=charsheet.CharacterSheet(student, screen=self.screen, camp=self.camp), screen=self.screen, predraw=self.view, caption="Advance Rank" )
     mymenu = charsheet.RightMenu( self.screen, predraw = myredraw )
     mymenu.add_item( "Advance {0}".format( student.mr_level.name ) , student.mr_level.__class__ )
     for j in student.levels:
         if j is not student.mr_level:
             mymenu.add_item( "Change to {0}".format( j.name ) , j.__class__ )
     jobs = set()
     for pc in self.camp.party:
         for j in pc.levels:
             jobs.add( j.__class__ )
     for j in student.levels:
         jobs.remove( j.__class__ )
     for j in jobs:
         if j.can_take_level( student ):
             mymenu.add_item( "Learn {0}".format( j.name ) , j )
     mymenu.sort()
     mymenu.add_alpha_keys()
     mymenu.add_item( "Cancel", False )
     myredraw.menu = mymenu
     it = mymenu.query()
     if it:
         improved_stat = student.advance( it )
         if improved_stat:
             self.alert( "{0} gains a rank in {1} \n and +1 {2}.".format( student, it.name, improved_stat ) )
         else:
             self.alert( "{0} gains a rank in {1}.".format( student, it.name ) )
示例#7
0
    def enter_library( self, explo ):
        '''Find out what the PC wants to do when entering library - shows menu'''
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=self.charsheets[ self.pc ], screen=explo.screen, predraw=explo.view, caption=self.caption )

        mymenu = charsheet.RightMenu( explo.screen, predraw = myredraw )
        mymenu.add_item( "Learn New Spell", self.learn_spell )
        mymenu.add_item( "Discard Known Spell", self.discard_spell )
        mymenu.add_item( "Exit", False )
        mymenu.add_alpha_keys()
        myredraw.menu = mymenu
        mymenu.quick_keys[ pygame.K_LEFT ] = -1
        mymenu.quick_keys[ pygame.K_RIGHT ] = 1

        while keep_going:
            it = mymenu.query()
            if it == -1:
                n = ( explo.camp.party.index(self.pc) + len( explo.camp.party ) - 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it == 1:
                n = ( explo.camp.party.index(self.pc) + 1 ) % len( explo.camp.party )
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[ self.pc ]
            elif it:
                # A method was selected. Deal with it.
                it( explo )
                myredraw.csheet = self.charsheets[ self.pc ]
            else:
                keep_going = False
示例#8
0
    def sell_items(self, explo):
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer(
            csheet=self.charsheets[self.pc],
            screen=explo.screen,
            predraw=explo.view,
            caption="Sell Items")
        last_item = 1

        while keep_going:
            mymenu = charsheet.RightMenu(explo.screen, predraw=myredraw)

            self.pc.contents.tidy()
            for s in self.pc.contents:
                if s.equipped:
                    mymenu.add_item(
                        "*{0} ({1}gp)".format(s, self.sale_price(s)), s)
                elif s.slot != items.NOSLOT and not self.pc.can_equip(s):
                    mymenu.add_item(
                        "#{0} ({1}gp)".format(s, self.sale_price(s)), s)
                else:
                    mymenu.add_item(
                        "{0} ({1}gp)".format(s, self.sale_price(s)), s)
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item("Exit", False)
            mymenu.set_item_by_position(last_item)
            myredraw.menu = mymenu
            mymenu.quick_keys[pygame.K_LEFT] = -1
            mymenu.quick_keys[pygame.K_RIGHT] = 1

            it = mymenu.query()
            last_item = mymenu.selected_item
            if it is -1:
                n = (explo.camp.party.index(self.pc) + len(explo.camp.party) -
                     1) % len(explo.camp.party)
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it is 1:
                n = (explo.camp.party.index(self.pc) + 1) % len(
                    explo.camp.party)
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it:
                # An item was selected. Deal with it.
                self.pc.contents.remove(it)
                explo.camp.gold += self.sale_price(it)
                self.improve_friendliness(explo, it, modifier=-20)
                if it.enhancement:
                    it.identified = True
                    self.wares.append(it)
                myredraw.caption = "You have sold {0}.".format(it)
                if it.equipped:
                    myredraw.csheet.regenerate_avatar()
                    explo.view.regenerate_avatars(explo.camp.party)

            else:
                keep_going = False
示例#9
0
    def buy_items(self, explo):
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer(
            csheet=self.charsheets[self.pc],
            screen=explo.screen,
            predraw=explo.view,
            caption="Buy Items")
        last_selected = 0

        while keep_going:
            mymenu = self.make_wares_menu(explo, myredraw)
            mymenu.set_item_by_position(last_selected)
            it = mymenu.query()
            last_selected = mymenu.selected_item
            if it is -1:
                n = (explo.camp.party.index(self.pc) + len(explo.camp.party) -
                     1) % len(explo.camp.party)
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it is 1:
                n = (explo.camp.party.index(self.pc) + 1) % len(
                    explo.camp.party)
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it:
                # An item was selected. Deal with it.
                cost = self.calc_purchase_price(explo, it)
                if cost > explo.camp.gold:
                    myredraw.caption = "You can't afford it!"
                elif not self.pc.can_take_item(it) or not self.pc.is_alright():
                    myredraw.caption = "You can't carry it!"
                else:
                    if it.enhancement:
                        it2 = it
                        self.wares.remove(it)
                    else:
                        it2 = copy.copy(it)
                        if it.itemtype in self.LIMITED_QUANTITY_ITEMS:
                            if hasattr(it, "shop_quantity"):
                                it.shop_quantity += -1
                                if it.shop_quantity < 1:
                                    self.wares.remove(it)
                            else:
                                self.wares.remove(it)

                    self.pc.contents.append(it2)
                    self.improve_friendliness(explo, it2)
                    explo.camp.gold -= cost
                    myredraw.caption = "You have bought {0}.".format(it2)
            else:
                keep_going = False
示例#10
0
    def identify_items(self, explo):
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer(
            csheet=self.charsheets[self.pc],
            screen=explo.screen,
            predraw=explo.view,
            caption="Identify Items")

        while keep_going:
            mymenu = charsheet.RightMenu(explo.screen, predraw=myredraw)

            for s in self.pc.contents:
                if not s.identified:
                    if s.equipped:
                        mymenu.add_item(
                            "*{0} ({1}gp)".format(s, self.IDENTIFY_PRICE), s)
                    elif s.slot != items.NOSLOT and not self.pc.can_equip(s):
                        mymenu.add_item(
                            "#{0} ({1}gp)".format(s, self.IDENTIFY_PRICE), s)
                    else:
                        mymenu.add_item(
                            "{0} ({1}gp)".format(s, self.IDENTIFY_PRICE), s)
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item("Exit", False)
            myredraw.menu = mymenu
            mymenu.quick_keys[pygame.K_LEFT] = -1
            mymenu.quick_keys[pygame.K_RIGHT] = 1

            it = mymenu.query()
            if it is -1:
                n = (explo.camp.party.index(self.pc) + len(explo.camp.party) -
                     1) % len(explo.camp.party)
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it is 1:
                n = (explo.camp.party.index(self.pc) + 1) % len(
                    explo.camp.party)
                self.pc = explo.camp.party[n]
                myredraw.csheet = self.charsheets[self.pc]
            elif it:
                # An item was selected. Deal with it.
                if explo.camp.gold >= self.IDENTIFY_PRICE:
                    it.identified = True
                    explo.camp.gold -= self.IDENTIFY_PRICE
                    myredraw.caption = "It's a {0}!".format(it)
                else:
                    myredraw.caption = "You can't afford it."
            else:
                keep_going = False
示例#11
0
    def choose_job( self, explo ):
        ''' Choose job. Simple check for your level / job level '''
        myredraw = charsheet.CharacterViewRedrawer( csheet=self.charsheets[ self.pc ], screen=explo.screen, predraw=explo.view, caption="What job will {0} learn?".format(self.pc) )
        mymenu = charsheet.RightMenu( explo.screen, predraw = myredraw, add_desc=False )

        for j in self.jobs:
            if j.can_take_level( self.pc ):
                # if you can even take the job because of level
                mymenu.add_item( j.name, j )
        mymenu.sort()
        mymenu.add_alpha_keys()
        mymenu.add_item( "Exit", False )
        myredraw.menu = mymenu

        it = mymenu.query()
        if it:
            self.pc.advance( it )
    def view_party( self, n, can_switch=True ):
        if n >= len( self.camp.party ):
            n = 0
        pc = self.camp.party[ n ]
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=charsheet.CharacterSheet(pc, screen=self.screen, camp=self.camp), screen=self.screen, predraw=self.view, caption="View Party" )

        while keep_going:
            mymenu = charsheet.RightMenu( self.screen, predraw = myredraw )
            pc.contents.tidy()
            for i in pc.contents:
                if i.equipped:
                    mymenu.add_item( "*" + str( i ) , i )
                elif i.slot != items.NOSLOT and not pc.can_equip( i ):
                    mymenu.add_item( "#" + str( i ) , i )
                else:
                    mymenu.add_item( str( i ) , i )
            if pc.xp > pc.xp_for_next_level():
                mymenu.add_item( "!!!Advance Rank!!!", 999 )
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item( "Exit", False )
            myredraw.menu = mymenu
            if can_switch:
                mymenu.quick_keys[ pygame.K_LEFT ] = -1
                mymenu.quick_keys[ pygame.K_RIGHT ] = 1

            it = mymenu.query()
            if it is -1:
                n = ( n + len( self.camp.party ) - 1 ) % len( self.camp.party )
                pc = self.camp.party[n]
                myredraw.csheet = charsheet.CharacterSheet(pc, screen=self.screen, camp=self.camp)
            elif it is 1:
                n = ( n + 1 ) % len( self.camp.party )
                pc = self.camp.party[n]
                myredraw.csheet = charsheet.CharacterSheet(pc, screen=self.screen, camp=self.camp)
            elif it is 999:
                self.do_level_training( pc )
                keep_going = False
            elif it:
                # An item was selected. Deal with it.
                if not self.equip_or_whatevs( it, pc, myredraw ):
                    keep_going = False
            else:
                keep_going = False
示例#13
0
    def __call__(self, explo):
        pc = explo.camp.party_spokesperson()
        myredraw = charsheet.CharacterViewRedrawer(
            csheet=charsheet.CharacterSheet(pc,
                                            screen=explo.screen,
                                            camp=explo.camp),
            screen=explo.screen,
            predraw=explo.view,
            caption=self.caption)

        while True:
            rpm = charsheet.RightMenu(explo.screen, predraw=myredraw)

            if any(not pc.is_alright()
                   for pc in explo.camp.party) or explo.camp.graveyard:
                rpm.add_item("Resurrection", self.resurrection, self.desc)
            if any((pc.is_alright() and pc.stat_damage)
                   for pc in explo.camp.party):
                rpm.add_item("Restoration", self.restoration, self.desc)
            if any(
                (pc.is_alright()
                 and pc.condition.has_enchantment_of_type(enchantments.POISON))
                    for pc in explo.camp.party):
                rpm.add_item("Cure Poison", self.cure_poison, self.desc)
            if any(
                (pc.is_alright()
                 and pc.condition.has_enchantment_of_type(enchantments.CURSE))
                    for pc in explo.camp.party):
                rpm.add_item("Remove Curse", self.remove_curse, self.desc)
            rpm.add_item("Exit {0}".format(self.caption), False, self.desc)
            rpm.add_alpha_keys()

            it = rpm.query()

            if it:
                it(explo)
            else:
                break
示例#14
0
    def open_menu( self, camp, screen, predraw=None ):
        # Save the most recently used adventurer's guild. If all characters die,
        # this is where the game restarts.
        camp.mru_advguild = (self.scene,self)
        mypartysheet = charsheet.PartySheet( camp.party , screen=screen, camp=camp )
        myredraw = charsheet.CharacterViewRedrawer( csheet=mypartysheet, screen=screen, predraw=predraw, caption=self.caption )

        while True:
            rpm = charsheet.RightMenu( screen, predraw=myredraw )

            rpm.add_item( "Add Members", self.add_members )
            rpm.add_item( "Remove Members", self.remove_members )
            rpm.add_item( "Exit {0}".format(self.caption), False, self.desc )
            rpm.add_alpha_keys()

            it = rpm.query()

            if it:
                it( camp, screen, predraw )
                mypartysheet.regenerate_avatars()
            else:
                break
        camp.save( screen )
    def reorder_party( self ):
        new_party_order = list()
        psheet = charsheet.PartySheet( new_party_order, screen=self.screen, camp=self.camp )
        myredraw = charsheet.CharacterViewRedrawer( csheet=psheet, screen=self.screen, predraw=self.view, caption="Reorder Party" )

        while self.camp.party:
            mymenu = charsheet.RightMenu( self.screen, predraw = myredraw )
            for pc in self.camp.party:
                mymenu.add_item( str( pc ), pc )
            mymenu.add_alpha_keys()
            mymenu.add_item( "Exit", False )
            myredraw.menu = mymenu

            it = mymenu.query()
            if it:
                self.camp.party.remove( it )
                new_party_order.append( it )
                psheet.regenerate_avatars()
            else:
                break
        if self.camp.party:
            new_party_order += self.camp.party
        self.camp.party = new_party_order
    def cast_explo_spell( self, n, can_switch=True ):
        if n >= len( self.camp.party ):
            n = 0
        pc = self.camp.party[ n ]
        keep_going = True
        myredraw = charsheet.CharacterViewRedrawer( csheet=charsheet.CharacterSheet(pc, screen=self.screen, camp=self.camp), screen=self.screen, predraw=self.view, caption="Spells & Techniques" )

        while keep_going:
            mymenu = charsheet.RightMenu( self.screen, predraw = myredraw )
            self.add_spells_for_pc( pc, mymenu )
            mymenu.sort()
            mymenu.add_alpha_keys()
            mymenu.add_item( "Exit", False )
            myredraw.menu = mymenu
            if can_switch:
                mymenu.quick_keys[ pygame.K_LEFT ] = -1
                mymenu.quick_keys[ pygame.K_RIGHT ] = 1

            it = mymenu.query()
            if it is -1:
                n = ( n + len( self.camp.party ) - 1 ) % len( self.camp.party )
                pc = self.camp.party[n]
                myredraw.csheet = charsheet.CharacterSheet(pc, screen=self.screen, camp=self.camp)
            elif it is 1:
                n = ( n + 1 ) % len( self.camp.party )
                pc = self.camp.party[n]
                myredraw.csheet = charsheet.CharacterSheet(pc, screen=self.screen, camp=self.camp)

            elif it:
                # A spell was selected. Deal with it.
                if pc.is_alright() and it.can_be_invoked( pc ):
                    self.pc_use_technique( pc, it, it.exp_tar )
                else:
                    self.alert( "That technique cannot be used right now." )
                keep_going = False
            else:
                keep_going = False
 def probe( self, target ):
     csheet = charsheet.CharacterSheet( target, screen=self.screen )
     myredraw = charsheet.CharacterViewRedrawer( csheet=csheet, screen=self.screen, caption="Probe", predraw=self.view)
     mymenu = charsheet.RightMenu( self.screen, predraw=myredraw )
     mymenu.add_item( "Close" , -1 )
     mymenu.query()