def new_game():
    global player, inventory, game_msgs, game_state, dungeon_level

    #create object representing the player
    entity_component = Entity(5)
    GameState.player = Object(0, 0, '@', 'player', libtcod.white, blocks=True, entity=entity_component)

    GameState.player.level = 1

    #generate map (at this point it's not drawn to the screen)
    dungeon_level = 1
    Map.make_map()
    initialize_fov()

    game_state = 'playing'
    GameState.inventory = []

    #create the list of game messages and their colors, starts empty
    GameState.game_msgs = []

    #a warm welcoming message!
    GUI.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)

    #initial equipment: a dagger
    equipment_component = Equipment(slot='right hand', power_bonus=2)
    obj = Object(0, 0, '-', 'dagger', libtcod.sky, equipment=equipment_component)
    GameState.inventory.append(obj)
    equipment_component.equip()
    obj.always_visible = True
Ejemplo n.º 2
0
def new_game():
    settings.init_new_game()

    profession = choose_job()

    if profession is None:
        return None

    profession_component = Profession(profession=profession)
    combatant_component = Combatant(xp=0,
                                    level=1,
                                    death_function=player_death,
                                    profession=profession_component)
    settings.player = Object(0,
                             0,
                             '@',
                             'player',
                             tcod.white,
                             blocks=True,
                             combatant=combatant_component)
    settings.player.combatant.profession.get_abilities_for_level()
    settings.dungeon_level = 1
    settings.mouse_x = settings.player.x
    settings.mouse_y = settings.player.y

    make_map()
    settings.save_level_state()
    initialize_fov()

    settings.game_state = 'playing'

    equipment = 'dagger'
    equipment_component = Equipment(equipment=equipment)
    obj = Object(0,
                 0,
                 '-',
                 'dagger',
                 tcod.light_blue,
                 equipment=equipment_component)
    settings.player.combatant.inventory.append(obj)
    settings.player.combatant.equip_item_to_slot(equipment_component)
    obj.always_visible = True

    equipment = 'clothes'
    equipment_component = Equipment(equipment=equipment)
    obj = Object(0,
                 0,
                 '#',
                 'clothes',
                 tcod.light_gray,
                 equipment=equipment_component)
    settings.player.combatant.inventory.append(obj)
    settings.player.combatant.toggle_equipment_state(equipment_component)
    obj.always_visible = True
    return "go"
    def __init__(self,modelPath,tag,health, offense):
        Equipment.__init__(self)

        self.model = loader.loadModel(modelPath)
        self.tag = tag
        self.health = health
        self.offense = offense

        if self.health != 0:
            self.isHealth = True

        if self.offense != 0:
            self.isOffense = True
Ejemplo n.º 4
0
def main():
    player = Character(input('What is your name, slave?\n'), 15)
    orc = Character('Foul orc')
    troll = Character('Fetid troll')
    knight = Character(
        'Knight', 10, 5, 1, None,
        Equipment(Weapon('Sword', '1hsw', 2), Armor('Shiny armor', 1)))
    arena = Arena()
    fight = FightManager(arena, [player, orc, troll, knight], player)

    print('You enter the arena.')
    print(knight.equipment.weapon)

    wageFight(fight)

    corpses = fight.arena.corpses

    if fight.hasPlayer():
        print('You survived another fight.')
        #Loot and continue
        lootCorpses(player, corpses)
    elif len(fight.arena.fighters) > 0:
        winner = fight.arena.fighters.pop(0)
        print('%s won the fight !' % winner.name)
    else:
        print(
            'Draw ! All fighters lost their lives, the crowd cheers to revive the most brutal.'
        )
        #Continue if fought best

    print(player)
    print(player.inventory.items)

    print('End.')
 def load(self):
     FILE = open(self.name, 'r')
     for string in FILE:
         x = string.split()
         self.arr[x[0]] = Equipment(str(x[0]), str(x[1]), int(x[2]),
                                    int(x[3]))
     return self.arr
Ejemplo n.º 6
0
 def forge(self,name,type,level_bonus,level):
     weapon=Equipment(name,type,level_bonus,level)
     if(weapon not in self.arr):
         self.arr[weapon.name]=weapon
         self.save_data()
         print("Successfuly added to weapons!")
     return weapon
Ejemplo n.º 7
0
 def load(self):
     file = open(self.name, 'r')
     for string in file:
         x = string.split()
         self.weapon_list[x[0]] = Equipment(str(x[0]), str(x[1]), int(x[2]),
                                            int(x[3]))
     return self.weapon_list
Ejemplo n.º 8
0
 def Load(self, fileName):
     with open(fileName) as fileData:
         jsonData = json.load(fileData)
     equipments = []
     for quipSon in jsonData["Equipments"]:
         equipment = Equipment(quipSon["ID"], quipSon["Type"], quipSon["ATK %"], quipSon["ATK +"], quipSon["DEF %"], quipSon["DEF +"], quipSon["Pincer ATK %"], quipSon["Pincer ATK +"], quipSon["HP %"], quipSon["HP +"], quipSon["CRT Rate"], quipSon["CRT DMG"], quipSon["ACC"], quipSon["RES"], quipSon["Set"], quipSon["Stars"], quipSon["+"])
         equipments.append(equipment)
     return equipments
Ejemplo n.º 9
0
    def ToString(self):
        thisString = "Guardian #" + str(self.id) + "\n"
        thisString += "  Name             : " + str(self.name) + "\n"

        thisString += "  Equipment IDs    : "
        for equipmentType in EquipmentType:
            if self.equipments.has_key(equipmentType):
                thisString += str(self.equipments[equipmentType].id) + " "
            else:
                thisString += "0 "
        thisString += "\n"

        thisString += "                           ATK       DEF    PINCER        HP   CRTRATE    CRTDMG       ACC       RES\n"

        thisString += "  Base Statistic   :"
        for statisticType in StatisticType:
            thisString += str(self.statistics[statisticType]).rjust(10)
        thisString += "\n"

        thisString += "  Collection Effect:"
        for statisticType in StatisticType:
            thisString += str(self.collectionEffects[statisticType]).rjust(10)
        thisString += "\n"

        for equipmentType in EquipmentType:
            thisString += (equipmentType.name + " Buff:").rjust(20)
            for statisticType in StatisticType:
                if self.equipments.has_key(equipmentType):
                    thisString += str(
                        self.equipments[equipmentType].GetBuffedStatistic(
                            statisticType, self)).rjust(10)
            thisString += "\n"

        equipmentSet = self.GetEquipmentSet()
        for set in equipmentSet:
            thisString += "  " + str(set).ljust(16) + " :"
            setBuffPercent = Equipment.GetSetBuff(set, self)
            for statisticType in StatisticType:
                thisString += str(setBuffPercent.get(statisticType,
                                                     0)).rjust(10)
            for specialAbility in SpecialAbility:
                thisString += "    " + str(
                    setBuffPercent.get(specialAbility, ""))
            thisString += "\n"

        finalStats = self.CalculateFinalStats()
        thisString += "  Final Statistic  :"
        for statisticType in StatisticType:
            thisString += str(finalStats[statisticType]).rjust(10)
        thisString += "\n"

        thisString += "  Average ATK      : " + str(
            Guardian.GetAverageAttack(finalStats))

        return thisString
Ejemplo n.º 10
0
 def forge(self, *args):
     try:
         name, eq_type, level_bonus, level = args[0], args[1], args[2], args[3]
     except LookupError:
         return 'Некорректное кол-во аргументов!'
     weapon = Equipment(name, eq_type, level_bonus, level)
     if weapon not in self.weapon_list:
         self.weapon_list[weapon.name] = weapon
         self.save_data()
         return "Новое оружие создано!"
     return "Успешно!", weapon
Ejemplo n.º 11
0
def new_game():
    fighter_component = Fighter(hp=30, defense=2, power=5,
                                xp=0, death_function=player_death)
    settings.player = Object(0, 0, '@', 'player', color.white, blocks=True,
                             fighter=fighter_component)

    settings.player.level = 1
    settings.dungeon_level = 1
    make_map()
    handle_keys.initialize_fov()
    settings.game_state = 'playing'
    settings.inventory = []
    settings.game_msgs = []

    message('Welcome stranger. Prepare to perish in the ' +
            'Tombs of the Ancient Kings.', color.red)
    equipment_component = Equipment(slot='right hand', power_bonus=2)
    obj = Object(0, 0, '-', 'dagger', color.sky,
                 equipment=equipment_component)
    settings.inventory.append(obj)
    equipment_component.equip()
    obj.always_visible = True
Ejemplo n.º 12
0
 def forge(self, user_data, *args):
     # Функция позволяет создать новое
     # оружие и добавить его в словарь
     try:
         name, eq_type, level_bonus, level = args[0], args[1], args[
             2], args[3]
     except LookupError:
         return 'Invalid number of arguments!'
     weapon = Equipment(name, eq_type, level_bonus, level)
     if weapon not in self.weapon_list:
         self.weapon_list[weapon.name] = weapon
         self.save_data()
         return "New weapon created!"
     return "Success!", weapon
Ejemplo n.º 13
0
 def __init__(self):
     self.name = 'Richard'
     self.max_hp = 50
     self.hp = self.max_hp
     self.lvl = 1
     self.exp = 0
     self._expForLvlUp = 30
     self.damage = 10
     self.defence = 0
     self.atk = ''
     self.defend = ''
     self.inventory = Inventory()
     self.equipment = Equipment()
     self.gold = 0
     self.rewards = Rewards()
Ejemplo n.º 14
0
 def __init__(self,
              name,
              hp=10,
              strength=5,
              toughness=1,
              inventory=None,
              equipment=None):
     self.name = name
     self.maxHp = hp
     self.hp = hp
     self.strength = strength
     self.toughness = toughness
     self.equipment = Equipment() if equipment is None else equipment
     self.inventory = Inventory([HealingPotion()
                                 ]) if inventory is None else inventory
Ejemplo n.º 15
0
	def __init__(self):
		self.attack_power = 0
		self.defense_rating = 0
		
		self.equipmentest = Equipment()

		self.equipment_armor_body = 3500
		self.equipment_weapon_primary = 5
		
		self.attributes = Attributes()
		self.stats = Stats(self.attributes)
		self.current_stats = Stats(self.attributes)
		self.level = 1
		self.name = ""		
		
		self.gear_up()
Ejemplo n.º 16
0
 def CalculateFinalStats(self):
     finalStats = {}
     for statisticType in StatisticType:
         finalStats[statisticType] = self.statistics[statisticType]
         finalStats[statisticType] += self.collectionEffects[statisticType]
         if len(self.equipments) > 0:
             for equipmentType in EquipmentType:
                 if self.equipments.has_key(equipmentType):
                     finalStats[statisticType] += self.equipments[
                         equipmentType].GetBuffedStatistic(
                             statisticType, self)
     equipmentSet = self.GetEquipmentSet()
     for set in equipmentSet:
         setBuffPercent = Equipment.GetSetBuff(set, self)
         for statisticType in StatisticType:
             finalStats[statisticType] += setBuffPercent.get(
                 statisticType, 0)
     return finalStats
Ejemplo n.º 17
0
 def Shopping(self):
     if self.screen.screenType == ScreenType.GAME_HOME:
         self.Log("Press Shop button")
         self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Home_Shop))
     elif self.screen.screenType == ScreenType.SHOP:
         screenPiece = self.screen.Find("Shop_MagicShopAvailable.png")
         if screenPiece is not None:
             self.Log("Magic shop is available. Open magic shop...")
             self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Shop_MagicShop))
         else:
             screenPiece = self.screen.Find("Shop_MagicShopOpening.png")
             if screenPiece is not None:
                 self.Log("Magic shop is opening. Find good items...")
                 self.BuyGoodItemInMagicShop()
             else:
                 self.Log("Magic Shop isn't available. Go home...")
                 self.gameState = GameState.PROMOTION_BATTLE
                 self.PlayDefault()
     elif self.screen.screenType == ScreenType.SHOP_DIALOG_IS_OPENNING:
         screenPiece = self.screen.Find("Shop_DialogIsOpening_MysticalBook.png")
         if screenPiece is not None:
             self.Log("Buy mystical book")
             self.purchaseConfirmed = True
             self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Dialog_BuyEquipment_Purchase))
         else:
             equipment = Equipment(self.screen)
             if equipment.isGood:
                 self.Log("Good equipment. Buy!")
                 self.purchaseConfirmed = True
                 self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Dialog_BuyEquipment_Purchase))
             else:
                 self.Log("Not good equipment. Close")
                 self.purchaseConfirmed = False
                 self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Dialog_BuyEquipment_Cancel))
     elif self.screen.screenType == ScreenType.SHOP_DIALOG_PURCHASE_CONFIRMATION:
         if self.purchaseConfirmed:
             self.Log("Confirm")
             self.purchaseConfirmed = False
             self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Dialog_BuyEquipment_PurchaseConfirmation_OK))
         else:
             self.Log("Cancel")
             self.device.TouchAtPosition(ButtonPositions.GetPosition(Button.Dialog_BuyEquipment_PurchaseConfirmation_Cancel))
     else:
         self.PlayDefault()
Ejemplo n.º 18
0
def topologyGenerator(rootXML, rootSSH, baseVoltageList, substationList,
                      voltageLevelList, generatingUnitList,
                      regulatingControlList, powerTransformerList,
                      energyConsumerList, powerTransformerEndList, breakerList,
                      ratioTapChangerList, synchronousMachineList,
                      ACLinesList):

    # Initialize variables to use

    nodeNumber = 1
    powerGrid = [Node]
    busbarSectionList = []

    #Find all Coonectivity Nodes

    for n in rootXML.findall('ConnectivityNode'):
        IDCN = n.get('ID')
        nameCN = n.find('IdentifiedObject.name').text
        containerCN = n.find(
            'ConnectivityNode.ConnectivityNodeContainer').attrib['resource']
        powerGrid.append(Node(nodeNumber, IDCN, nameCN, containerCN))
        TNum = 0

        # Find terminals and add them to the CN

        for nn in rootXML.findall('Terminal'):
            CNTerminal = nn.find(
                'Terminal.ConnectivityNode').attrib['resource']
            if CNTerminal[1:] == IDCN:
                IDTerminal = nn.get('ID')
                nameTerminal = nn.find('IdentifiedObject.name').text
                CETerminal = nn.find(
                    'Terminal.ConductingEquipment').attrib['resource']
                powerGrid[nodeNumber].addTerminal(
                    Terminal(IDTerminal, nameTerminal, CETerminal, CNTerminal))

                TNum += 1

                # Find the Conducting Equipment and add them to the Terminal
                # First, let's look for bus bars

                for nnn in rootXML.findall('BusbarSection'):
                    IDBB = nnn.get('ID')
                    if IDBB == CETerminal[1:]:
                        nameBB = nnn.find('IdentifiedObject.name').text
                        equipmentContBB = nnn.find(
                            'Equipment.EquipmentContainer').attrib['resource']
                        busbarSectionList.append(
                            Equipment(IDBB, nameBB, equipmentContBB))
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            Equipment(IDBB, nameBB, equipmentContBB))

                # Now, let's find the Power Transformers

                pos = 0

                for _ in powerTransformerList:
                    IDPowTrans = powerTransformerList[pos].IDPowTrans
                    if IDPowTrans == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            powerTransformerList[pos])
                    pos += 1

                # Now, let's find the Breakers

                pos = 0

                for _ in breakerList:
                    IDBreaker = breakerList[pos].IDBreaker
                    if IDBreaker == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            breakerList[pos])
                    pos += 1

                # Now, let's find the Generation Units

                pos = 0

                for _ in generatingUnitList:
                    IDGenUnit = generatingUnitList[pos].IDGenUnit
                    if IDGenUnit == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            generatingUnitList[pos])
                    pos += 1

                # Now, let's find the Regulating Units

                pos = 0

                for _ in regulatingControlList:
                    IDRegCtrl = regulatingControlList[pos].IDRegCtrl
                    if IDRegCtrl == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            regulatingControlList[pos])
                    pos += 1

                # Are you not getting bored? We find the loads

                pos = 0

                for _ in energyConsumerList:
                    IDEnergyConsumer = energyConsumerList[pos].IDEnergyConsumer
                    if IDEnergyConsumer == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            IDEnergyConsumer[pos])
                    pos += 1

                # Now, we find the Synchronous Machine

                pos = 0

                for _ in synchronousMachineList:
                    IDSynchMach = synchronousMachineList[pos].IDSynchMach
                    if IDSynchMach == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            synchronousMachineList[pos])
                    pos += 1

                # Almost finally... the Power Transformers End

                pos = 0

                for _ in powerTransformerEndList:
                    IDPTEnd = powerTransformerEndList[pos].IDPTEnd
                    if IDPTEnd == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            powerTransformerEndList[pos])
                    pos += 1

                # Finally, the AC Lines

                pos = 0

                for _ in ACLinesList:
                    IDLine = ACLinesList[pos].IDLine
                    if IDLine == CETerminal[1:]:
                        powerGrid[nodeNumber].terminalList[TNum].addCE(
                            ACLinesList[pos])
                    pos += 1

        nodeNumber += 1

    # GraphMyPowerGrid
    yBusMtx = CalculateYBusMatrix(voltageLevelList, busbarSectionList,
                                  powerTransformerEndList,
                                  powerTransformerList, baseVoltageList,
                                  ACLinesList, energyConsumerList)

    for element in yBusMtx:
        if element != 0:
            print(element)

    print()
    print("All other elements are cero")
Ejemplo n.º 19
0
from controls import Controller
from char import Charapter
from Equipment import Equipment
w=Equipment('testarmor','Inhand',0,0)
print(w.call_brief())

controls=Controller()
controls.start()
Ejemplo n.º 20
0
    def loadMeals(self):
        # read file
        with open('demo-data.json', 'r') as demoDataFile:
            demoData = demoDataFile.read()

        # parse file
        demoDataJsonObject = json.loads(demoData)

        print("length: " + str(len(demoDataJsonObject)))

        meals = []

        for mealData in demoDataJsonObject:
            ingredientsObject = mealData['ingredients']
            ingredients = []
            for ingredientData in ingredientsObject:
                newIngredient = Ingredient(ingredientData['name'],
                                           ingredientData['quantity'],
                                           ingredientData['units'],
                                           ingredientData['size'])
                ingredients.append(newIngredient)
            methodStepsObject = mealData['method']
            methodSteps = []
            for methodStepData in methodStepsObject:
                newMethodStep = MethodStep(methodStepData['stepNumber'],
                                           methodStepData['stepDescription'])
                methodSteps.append(newMethodStep)
            equipmentObject = mealData['equipment']
            equipment = []
            for equipmentData in equipmentObject:
                newEquipment = Equipment(equipmentData['name'],
                                         equipmentData['quantityRequired'])
                equipment.append(newEquipment)
            dietaryNotesObject = mealData['dietaryNotes']
            dietaryNotes = []
            for dietaryNotesData in dietaryNotesObject:
                newdietaryNote = DietaryNote(dietaryNotesData['note'])
                dietaryNotes.append(newdietaryNote)

            prepTimeObject = mealData['prepTime']
            prepTime = timedelta(hours=prepTimeObject['hours'],
                                 minutes=prepTimeObject['minutes'],
                                 seconds=prepTimeObject['seconds'])

            print("prepTime: " + str(prepTime))

            cookingTimeObject = mealData['cookingTime']
            cookingTime = timedelta(hours=cookingTimeObject['hours'],
                                    minutes=cookingTimeObject['minutes'],
                                    seconds=cookingTimeObject['seconds'])

            print("cookingTime: " + str(cookingTime))

            newMeal = Meal(mealData['name'], mealData['description'],
                           ingredients, methodSteps,
                           mealData['difficultyRating'], equipment,
                           mealData['priceRating'], dietaryNotes, prepTime,
                           cookingTime)
            meals.append(newMeal)

        return meals