示例#1
0
def test_actor():
    components = {
        "name": "actor",
        "char": "x",
        "color": (255, 255, 255),
        "ai": HostileAI(),
        "fighter": Fighter(max_hp=1, base_ac=10),
        "offense": OffenseComponent(Attack('zap', [1])),
        "level": Level(xp_given=1, difficulty=0),
        "energy": EnergyComponent(refill=10)
    }
    return Actor(**components)
示例#2
0
文件: player.py 项目: elunna/labhack
    def __init__(self):
        super().__init__(
            name="player",
            player=True,  # Let's us work with the player component around the game.
            char="@",
            color=(255, 255, 255),
            ai=None,
            equipment=Equipment(),
            fighter=Fighter(max_hp=30, base_ac=10),
            offense=OffenseComponent(Attack('punch', [2])),
            attributes=Attributes(base_strength=5),

            # Original inventory capacity is 267 because we have 26 lowercase letters plus $
            inventory=PlayerInventory(capacity=27),

            level=Level(level_up_base=20, difficulty=0),
            energy=EnergyComponent(refill=12),
            regeneration=Regeneration(),

            light=LightComponent(radius=1),
        )
示例#3
0
def test_init__single_attack():
    oc = OffenseComponent(Attack('bite', [8]))
    assert len(oc) == 1
    assert isinstance(oc.attacks, tuple)
示例#4
0
def test_init__2_attacks_tuple_():
    atk = Attack('bite', [8])
    oc = OffenseComponent(atk, atk)
    assert oc.attacks == (atk, atk)
示例#5
0
def test_init__tuple():
    atk = Attack('bite', [8])
    oc = OffenseComponent(atk)
    assert oc.attacks == (atk, )  # Single tuple
示例#6
0
文件: db.py 项目: elunna/labhack
from components.offense_comp import OffenseComponent
from components.energy import EnergyComponent
from components.fighter import Fighter
from components.item_comp import ItemComponent
from components.level import Level
from components.stackable import StackableComponent
from src.entity import Entity
from src.renderorder import RenderOrder

actor_dict = {
    "grid bug": {
        "char": "x",
        "color": tcod.purple,
        "ai": GridAI(),
        "fighter": Fighter(max_hp=1, base_ac=10),
        "offense": OffenseComponent(Attack('zap', [1])),
        "level": Level(xp_given=1, difficulty=0),
        "energy": EnergyComponent(refill=12)
    },

    "larva": {
        "char": "w",
        "color": tcod.white,
        "ai": HostileAI(),
        "fighter": Fighter(max_hp=1, base_ac=9),
        "offense": OffenseComponent(Attack('bite', [2])),
        "level": Level(xp_given=8, difficulty=2),
        "energy": EnergyComponent(refill=6)
    },

    "brown mold": {
示例#7
0
def test_min_dmg__2_die():
    atk = Attack('bite', [2, 2])
    result = atk.min_dmg()
    assert result == 2
示例#8
0
def test_to_text__1d8_plus_2d6():
    atk = Attack('bite', [8, 6, 6])
    assert atk.to_text() == '2d6+1d8'
示例#9
0
def test_to_text__1d2_1d10_1d8():
    atk = Attack('bite', [2, 10, 8])
    assert atk.to_text() == '1d2+1d8+1d10'
示例#10
0
def test_to_text__2d4():
    atk = Attack('bite', [4, 4])
    assert atk.to_text() == '2d4'
示例#11
0
def test_to_text__1d2():
    atk = Attack('bite', [2])
    assert atk.to_text() == '1d2'
示例#12
0
def test_init__roll_dies__1d2():
    atk = Attack('bite', [2])
    result = atk.roll_dies()
    assert result >= 1
    assert result <= 2
示例#13
0
def test_init__roll_dies__2d1():
    atk = Attack('bite', [1, 1])
    result = atk.roll_dies()
    assert result == 2
示例#14
0
def test_max_dmg__1_die():
    atk = Attack('bite', [2])
    result = atk.max_dmg()
    assert result == 2
示例#15
0
def testattacks():
    return [Attack('bite', [8]), Attack('bite', [8]), Attack('kick', [6, 6])]
示例#16
0
	def getmonsterfromdata(self, game_map, pos, speciesname, monsterlevel):
		# get the monster's data
		species = self.monsterdata.get(speciesname)
		if (not str(monsterlevel) in species):
			return False

		thismonsterdata = species.get(str(monsterlevel))
		fov_radius = thismonsterdata.get("fov_radius")
		attentiveness = thismonsterdata.get("attentiveness")
		truesight = (thismonsterdata.get("truesight") == "True")
		hp = thismonsterdata.get("hp")
		defense = thismonsterdata.get("defense")
		spdefense = thismonsterdata.get("spdefense")
		attack = thismonsterdata.get("attack")
		spattack = thismonsterdata.get("spattack")
		speed = thismonsterdata.get("speed")
		name = thismonsterdata.get("name")
		prey = thismonsterdata.get("prey")
		swim = (thismonsterdata.get("swim") == "True")
		char = species.get("char")
		if (speciesname == 'BOSSES'):
			color = colors.get('boss_monster_color')
		else:
			color = colors.get(
				self.monsterdata.get(
				"colors").get(monsterlevel))

		# create the monster
		attacks = []
		for atkparams in thismonsterdata.get("attacks").values():
			newatk = Attack(
				name=atkparams.get('name'),
				atk_power=int(atkparams.get('atk_power')),
				min_range=int(atkparams.get('min_range')),
				max_range=int(atkparams.get('max_range')),
				atk_type=attacktype(atkparams.get('atk_type')))
			attacks.append(newatk)

		fighter_component = Fighter(
			hp=hp, 
			defense=defense, 
			spdefense=spdefense, 
			attack=attack, 
			spattack=spattack, 
			speed=speed,
			attacks=attacks)
		ai_component = BasicMonster(game_map, 
			prey=prey, 
			swim=swim, 
			truesight=truesight, 
			fov_radius=fov_radius,
			attentiveness=attentiveness)
		monster = Entity(pos[0], pos[1], 
			char, 
			color, 
			name, 
			blocks=True,
			render_order=RenderOrder.ACTOR,
			fighter=fighter_component, 
			ai=ai_component)
		return monster
示例#17
0
def test_to_text__1d2_3d10_2d8():
    atk = Attack('bite', [2, 10, 10, 10, 8, 8])
    assert atk.to_text() == '1d2+2d8+3d10'