コード例 #1
0
    def createWeaponList(self):
        weaponList=[]
        rifleMag=Magazine(4,"normal","Standard Rifle Magazine")
        smgMag=Magazine(6,"normal","Standard SMG Magazine")
        shotgunMag=Magazine(2,"normal","Standard Shotgun Magazine")
        handgunMag=Magazine(8,"normal","Standard Handgun Magazine")
        knifeMag=Magazine(1000,"normal","fake Knife Mag")
        
        rifleSound=Sound().weaponSounds("Rifle")
        rifleSound.set_volume(.75)
        smgSound=Sound().weaponSounds("SMG")
        smgSound.set_volume(.5)
        shotgunSound=Sound().weaponSounds("Shotgun")
        handgunSound=Sound().weaponSounds("Handgun")
        knifeSound=Sound().weaponSounds("Knife")
        
        rifleReloadSound=Sound().reloadSounds("Rifle")
        smgReloadSound=Sound().reloadSounds("SMG")
        shotgunReloadSound=Sound().reloadSounds("Shotgun")
        handgunReloadSound=Sound().reloadSounds("Handgun")


        Rifle=Weapons(80,3,4,10,rifleMag,rifleSound,rifleReloadSound,"Rifle")
        SMG=Weapons(70,3,6,15,smgMag,smgSound,smgReloadSound,"SMG")
        Shotgun=Weapons(70,6,2,10,shotgunMag,shotgunSound,shotgunReloadSound,"Shotgun")
        Handgun=Weapons(80,2,8,15,handgunMag,handgunSound,handgunReloadSound,"Handgun")
        Knife=Weapons(100,20,1000,40,knifeMag,knifeSound,None,"Knife")
        weaponList.append(Rifle),weaponList.append(SMG),weaponList.append(Shotgun),weaponList.append(Handgun),weaponList.append(Knife)
        return weaponList
コード例 #2
0
    def combat(self,pod,user,playerBattleMap,alienBattleMap,playerEquipment,ranAway=0,playerDead=0):
    #taunt and shoot are shorthand for alien action options
        
        if ranAway !=0:
            done=1
        if playerDead!=0:
            done=1
        taunt="taunt"
        shoot="shoot"
        battleTurn=1 #1=Player,2=Alien.
        shotMissed=Sound().weaponSounds("Shot Miss")
        shotMissed.set_volume(1)
        turn=0 #turn ticks when turn passes, allowing for status aliments to fade after turns
        
        Combat.setCombatMusic()
        shotMissed.play()
        
        pygame.mixer.music.set_volume(1)
        pygame.mixer.music.play(-1,0)

    #*****************************************
    #lists holding combat actions/reactions
    #--------------------------------------
        actions=[] #actions holds enemy action choices.
        #totalHealth=[] #pulls hp from enemies in pod for ui purposes
        alienCoverStats=[] #pulls cover stats from enemiesi n pod for ui purposes
        playerCopyAlienCover=[] #copy of aliencoverstats made after they are cleared each turn. For long-term ui storage
    #*****************************************


    #main combat loop
        done=0
        while done==0:
            #At the start of combat, player chooses which cover they'll take.
            print ("You've touched down and found the enemies. Press the coorisponding number key to get into that over point.")
            os.system('cls' if os.name=='nt' else 'clear')
            user.changeCover(playerBattleMap)
            os.system('cls' if os.name=='nt' else 'clear')
    #show pod, make action selection, turn passed and it switches to alien.
            while battleTurn==1:
                ranAway=Combat.playerTurn(self,pod,user,alienBattleMap,playerBattleMap,shotMissed,playerEquipment)
                if ranAway==1:
                    done=1
                    os.system('cls' if os.name=='nt' else 'clear')
                    break
                done=Combat.checkIfVictory(pod,user)
                
                time.sleep(0.5)
                battleTurn=2
#if player chooses to run away, it returns runAway as 1. if 1, then done=1 and loop breaks, running funct again. ranAway, despite being an intitalized variable, stayed 1 and thus done
#also stayed 1. So with done=1, then there's no game loop and it's back to the main screen. Easy-peasy.

    #gets player position,then each alien in pod takes an action and cover. either taunt or shoot. clear results each time but store in sep list 1st
            while battleTurn==2:
                Combat.alienTurn(user,pod,actions,alienCoverStats,playerCopyAlienCover,alienBattleMap,playerBattleMap,shotMissed)
                playerDead=Combat.checkIfVictory(pod,user)
                if playerDead==1:
                    done=1
                    break
                
                input("Enter any key then hit enter to progress to your turn")
                battleTurn=1