示例#1
0
def dict2Character(d):
    if (d == "Empty"):
        return None
    name = d["Name"]
    style = d["Style"]
    weapon = d["Weapon"]["Name"]
    weaponbonus = (d["Weapon"]["Health"], d["Weapon"]["Attack"],
                   d["Weapon"]["Defense"], d["Weapon"]["Speed"],
                   d["Weapon"]["Type"])
    maxhealth = d["MaxHealth"]
    health = d["Health"]
    attack = d["Attack"]
    defense = d["Defense"]
    speed = d["Speed"]
    exp = d["Experience"]
    money = d["Money"]
    stash = d["Stash"]
    loc = [d["location"][0], d["location"][1], d["location"][2]]
    character = Character(Name=name,
                          Style=style,
                          Weapon=weapon,
                          WeaponBonus=weaponbonus,
                          Health=health,
                          Attack=attack,
                          Defense=defense,
                          Speed=speed,
                          Money=money,
                          Stash=stash,
                          location=loc,
                          Experience=exp)
    character.MaxHealth = maxhealth

    return character
示例#2
0
def dict2Character(d):
    name = d["Name"]
    style = d["Style"]
    weapon = d["Weapon"]["Name"]
    weaponbonus = (d["Weapon"]["Health"], d["Weapon"]["Attack"],
                   d["Weapon"]["Defense"], d["Weapon"]["Speed"],
                   d["Weapon"]["Type"])
    maxhealth = d["MaxHealth"]
    health = d["Health"]
    attack = d["Attack"]
    defense = d["Defense"]
    speed = d["Speed"]
    money = d["Money"]
    stash = d["Stash"]
    character = Character(Name=name,
                          Style=style,
                          Weapon=weapon,
                          WeaponBonus=weaponbonus,
                          Health=health,
                          Attack=attack,
                          Defense=defense,
                          Speed=speed,
                          Money=money,
                          Stash=stash)
    character.MaxHealth = maxhealth

    return character