コード例 #1
0
ファイル: worldgen.py プロジェクト: hovatterz/Reactor-3
def randomize_item_spawns():
	for building in WORLD_INFO['reference_map']['buildings']:
		_chunk_key = random.choice(alife.references.get_reference(building))
		_chunk = maps.get_chunk(_chunk_key)
		
		if not _chunk['ground']:
			continue
		
		if random.randint(0, 100)>=65:
			for i in range(0, 1+random.randint(0, 3)):
				_rand_pos = random.choice(_chunk['ground'])
				items.create_item('.22 rifle', position=[_rand_pos[0], _rand_pos[1], 2])
				items.create_item('.22 LR magazine', position=[_rand_pos[0], _rand_pos[1], 2])
			
			for i in range(10):
				_rand_pos = random.choice(_chunk['ground'])
				items.create_item('.22 LR cartridge', position=[_rand_pos[0], _rand_pos[1], 2])
		elif random.randint(0, 100)>=40:
			_items = ['corn', 'soda']
			for i in range(0, 1+random.randint(0, 3)):
				_rand_pos = random.choice(_chunk['ground'])
				items.create_item(random.choice(_items), position=[_rand_pos[0], _rand_pos[1], 2])
		
		for i in range(0, 1+random.randint(0, 3)):
			_rand_pos = random.choice(_chunk['ground'])
			items.create_item(random.choice(RECRUIT_ITEMS), position=[_rand_pos[0], _rand_pos[1], 2])
コード例 #2
0
ファイル: events.py プロジェクト: athros/Reactor-3
def create_cache_drop(pos, spawn_list):
    _player = LIFE[SETTINGS["controlling"]]
    _pos = spawns.get_spawn_point_around(pos, area=10)
    _direction = language.get_real_direction(numbers.direction_to(_player["pos"], _pos))

    for container in spawn_list:
        if not container["rarity"] > random.uniform(0, 1.0):
            continue

        _c = items.create_item(container["item"], position=[_pos[0], _pos[1], 2])

        for _inside_item in container["spawn_list"]:
            if _inside_item["rarity"] <= random.uniform(0, 1.0):
                continue

            _i = items.create_item(_inside_item["item"], position=[_pos[0], _pos[1], 2])

            if not items.can_store_item_in(_i, _c):
                items.delete_item(_i)

                continue

            items.store_item_in(_i, _c)

    effects.create_smoker(_pos, 300, color=tcod.orange)

    gfx.message("You see something parachuting to the ground to the %s." % _direction, style="event")
コード例 #3
0
ファイル: events.py プロジェクト: penny64/Reactor-3
def create_cache_drop(pos, spawn_list):
    _player = LIFE[SETTINGS['controlling']]
    _pos = spawns.get_spawn_point_around(pos, area=10)
    _direction = language.get_real_direction(
        numbers.direction_to(_player['pos'], _pos))

    for container in spawn_list:
        if not container['rarity'] > random.uniform(0, 1.0):
            continue

        _c = items.create_item(container['item'],
                               position=[_pos[0], _pos[1], 2])

        for _inside_item in container['spawn_list']:
            if _inside_item['rarity'] <= random.uniform(0, 1.0):
                continue

            _i = items.create_item(_inside_item['item'],
                                   position=[_pos[0], _pos[1], 2])

            if not items.can_store_item_in(_i, _c):
                items.delete_item(_i)

                continue

            items.store_item_in(_i, _c)

    effects.create_smoker(_pos, 300, color=tcod.orange)

    gfx.message('You see something parachuting to the ground to the %s.' %
                _direction,
                style='event')
コード例 #4
0
ファイル: artifacts.py プロジェクト: lawanfalalu/Reactor-3
def create_burner(chunk_key):
	_pos = random.choice(WORLD_INFO['chunk_map'][chunk_key]['ground'])[:]
	_pos.append(2)
	
	items.create_item('burner', position=_pos)
	effects.create_fire(_pos, intensity=8)
	effects.create_explosion(_pos, 4)
	
	print 'MAN CHECK THIS OUT!!!!!', chunk_key
コード例 #5
0
ファイル: weapons.py プロジェクト: flags/Reactor-3
def spawn_and_arm(weapon_name, feed_name, ammo_name, ammo_amount):
	_weapon = ITEMS[items.create_item(weapon_name)]
	_feed = ITEMS[items.create_item(feed_name)]
	
	for i in range(ammo_amount):
		_round = ITEMS[items.create_item(ammo_name)]
		_feed['rounds'].append(_round['uid'])
		_round['parent'] = _feed['uid']
	
	_weapon[_feed['type']] = _feed['uid']
	_feed['parent'] = _weapon['uid']
	
	return _weapon['uid']
コード例 #6
0
ファイル: weapons.py プロジェクト: lawanfalalu/Reactor-3
def spawn_and_arm(weapon_name, feed_name, ammo_name, ammo_amount):
    _weapon = ITEMS[items.create_item(weapon_name)]
    _feed = ITEMS[items.create_item(feed_name)]

    for i in range(ammo_amount):
        _round = ITEMS[items.create_item(ammo_name)]
        _feed['rounds'].append(_round['uid'])
        _round['parent'] = _feed['uid']

    _weapon[_feed['type']] = _feed['uid']
    _feed['parent'] = _weapon['uid']

    return _weapon['uid']
コード例 #7
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_backstages_quality_deltas(self):
     items = [
         create_item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
         create_item("Backstage passes to a TAFKAL80ETC concert", 10, 20),
         create_item("Backstage passes to a TAFKAL80ETC concert", 5, 20),
         create_item("Backstage passes to a TAFKAL80ETC concert", 0, 20)
     ]
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(21, items[0].quality)
     self.assertEqual(22, items[1].quality)
     self.assertEqual(23, items[2].quality)
     self.assertEqual(0, items[3].quality)
コード例 #8
0
ファイル: scripting.py プロジェクト: athros/Reactor-3
def execute(script, **kvargs):
	for function in script:
		_args = parse_arguments(script[function], **kvargs)
		
		if function == 'CREATE_AND_OWN_ITEM':
			_i = items.create_item(_args[0], position=_args[1])
			life.add_item_to_inventory(kvargs['owner'], _i)
		elif function == 'DELETE':
			items.delete_item(ITEMS[kvargs['item_uid']])
		elif function == 'LIGHT_FOLLOW':
			_item = ITEMS[kvargs['item_uid']]
			
			effects.create_light(items.get_pos(kvargs['item_uid']),
			                     (255, 255, 255),
			                     _item['brightness'],
			                     _item['light_shake'],
			                     follow_item=kvargs['item_uid'])
		elif function == 'LIGHT_FOLLOW_REMOVE':
			_item = ITEMS[kvargs['item_uid']]
			
			effects.delete_light_at(items.get_pos(kvargs['item_uid']))
		elif function == 'TOGGLE_BLOCK':
			_item = ITEMS[kvargs['item_uid']]
			
			if _item['blocking']:
				_item['blocking'] = False
			else:
				_item['blocking'] = True
		else:
			logging.error('Script: \'%s\' is not a valid function.' % function)
コード例 #9
0
def execute_recipe(life, item, recipe):
    _difficulty = get_recipe_difficulty(life, item, recipe)
    _dice_percentage = bad_numbers.roll(2, 5) / (10.0 + _difficulty)

    if _dice_percentage >= .75:
        _recipe_quality = 'success'
    elif _dice_percentage >= .5:
        _recipe_quality = 'partial_success'
    else:
        _recipe_quality = 'failure'

    if recipe['type'] == 'create_item':
        for create_item in recipe['create_item']:
            if not _recipe_quality in recipe['create_item'][create_item]:
                continue

            for i in range(recipe['create_item'][create_item][_recipe_quality]
                           ['amount']):
                _created_item = items.create_item(create_item)
                lfe.add_item_to_inventory(life, _created_item)

    if _recipe_quality in recipe['strings']:
        gfx.message(recipe['strings'][_recipe_quality])
    else:
        gfx.message('You finish crafting.')
コード例 #10
0
def execute(script, **kvargs):
    for function in script:
        _args = parse_arguments(script[function], **kvargs)

        if function == 'CREATE_AND_OWN_ITEM':
            _i = items.create_item(_args[0], position=_args[1])
            life.add_item_to_inventory(kvargs['owner'], _i)
        elif function == 'DELETE':
            items.delete_item(ITEMS[kvargs['item_uid']])
        elif function == 'LIGHT_FOLLOW':
            _item = ITEMS[kvargs['item_uid']]

            effects.create_light(items.get_pos(kvargs['item_uid']),
                                 (255, 255, 255),
                                 _item['brightness'],
                                 _item['light_shake'],
                                 follow_item=kvargs['item_uid'])
        elif function == 'LIGHT_FOLLOW_REMOVE':
            _item = ITEMS[kvargs['item_uid']]

            effects.delete_light_at(items.get_pos(kvargs['item_uid']))
        elif function == 'TOGGLE_BLOCK':
            _item = ITEMS[kvargs['item_uid']]

            if _item['blocking']:
                _item['blocking'] = False
            else:
                _item['blocking'] = True
        else:
            logging.error('Script: \'%s\' is not a valid function.' % function)
コード例 #11
0
ファイル: spawns.py プロジェクト: hovatterz/Reactor-3
def generate_life(life_class, amount=1, spawn_chunks=[]):
	_life_species = LIFE_CLASSES[life_class]['species']
	_spawn_list = []
	
	if spawn_chunks:
		_chunk_key = random.choice(spawn_chunks)
		_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
	else:
		_spawn = worldgen.get_spawn_point()
	
	for i in range(amount):
		if spawn_chunks:
			_chunk_key = random.choice(spawn_chunks)
			_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
		
		_alife = life.create_life(_life_species, map=WORLD_INFO['map'], position=[_spawn[0], _spawn[1], 2])
		
		for item in LIFE_CLASSES[life_class]['items']:
			print item
			for i in range(item.values()[0]):
				life.add_item_to_inventory(_alife, items.create_item(item.keys()[0]))
		
		for stat in LIFE_CLASSES[life_class]['stats']:
			_alife['stats'][stat] = LIFE_CLASSES[life_class]['stats'][stat]
		
		for goal in LIFE_CLASSES[life_class]['banned_goals']:
			alife.planner.remove_goal(_alife, goal)
		
		_spawn_list.append(_alife)
		
	return _spawn_list
コード例 #12
0
def generate_life(life_class,
                  amount=1,
                  position=None,
                  faction=None,
                  spawn_chunks=[]):
    _life_species = LIFE_CLASSES[life_class]['species']
    _spawn_list = []

    if not faction:
        faction = LIFE_CLASSES[life_class]['faction']

    if position:
        _spawn = position[:]

        if not len(_spawn) == 3:
            _spawn.append(2)

    elif spawn_chunks:
        _chunk_key = random.choice(spawn_chunks)
        _spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
    else:
        _spawn = worldgen.get_spawn_point()

    for i in range(amount):
        if spawn_chunks:
            _chunk_key = random.choice(spawn_chunks)
            _spawn = random.choice(
                alife.chunks.get_chunk(_chunk_key)['ground'])

        _alife = life.create_life(_life_species,
                                  position=[_spawn[0], _spawn[1], 2])

        if faction:
            alife.factions.add_member(faction, _alife['id'])

        for item in LIFE_CLASSES[life_class]['items']:
            for i in range(item['amount']):
                if 'equip' in item and item['equip']:
                    _equip = True
                else:
                    _equip = False

                life.add_item_to_inventory(_alife,
                                           items.create_item(item['item']),
                                           equip=_equip)

        for stat in LIFE_CLASSES[life_class]['stats']:
            _alife['stats'][stat] = LIFE_CLASSES[life_class]['stats'][stat]

        for goal in LIFE_CLASSES[life_class]['banned_goals']:
            alife.planner.remove_goal(_alife, goal)

        _spawn_list.append(_alife)

    return _spawn_list
コード例 #13
0
ファイル: effects.py プロジェクト: nathantypanski/Reactor-3
def create_gib(life, icon, size, limb, velocity, color=(tcod.white, None)):
	_gib = {'name': 'gib',
		'prefix': 'a',
		'type': 'magazine',
		'icon': icon,
		'flags': ['BLOODY'],
		'description': '%s\'s %s.' % (' '.join(life['name']), limb),
		'size': '%sx1' % size,
		'material': 'flesh',
		'thickness': size,
		'color': color}
	
	_i = items.get_item_from_uid(items.create_item('gib', position=life['pos'][:], item=_gib))
	_i['velocity'] = [numbers.clip(velocity[0], -3, 3), numbers.clip(velocity[1], -3, 3), velocity[2]]
	
	logging.debug('Created gib.')
コード例 #14
0
ファイル: spawns.py プロジェクト: flags/Reactor-3
def generate_life(life_class, amount=1, position=None, faction=None, spawn_chunks=[]):
	_life_species = LIFE_CLASSES[life_class]['species']
	_spawn_list = []
	
	if not faction:
		faction = LIFE_CLASSES[life_class]['faction']
	
	if position:
		_spawn = position[:]
		
		if not len(_spawn) == 3:
			_spawn.append(2)
		
	elif spawn_chunks:
		_chunk_key = random.choice(spawn_chunks)
		_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
	else:
		_spawn = worldgen.get_spawn_point()
	
	for i in range(amount):
		if spawn_chunks:
			_chunk_key = random.choice(spawn_chunks)
			_spawn = random.choice(alife.chunks.get_chunk(_chunk_key)['ground'])
		
		_alife = life.create_life(_life_species, position=[_spawn[0], _spawn[1], 2])
		
		if faction:
			alife.factions.add_member(faction, _alife['id'])
		
		for item in LIFE_CLASSES[life_class]['items']:
			for i in range(item['amount']):
				if 'equip' in item and item['equip']:
					_equip = True
				else:
					_equip = False
				
				life.add_item_to_inventory(_alife, items.create_item(item['item']), equip=_equip)
		
		for stat in LIFE_CLASSES[life_class]['stats']:
			_alife['stats'][stat] = LIFE_CLASSES[life_class]['stats'][stat]
		
		for goal in LIFE_CLASSES[life_class]['banned_goals']:
			alife.planner.remove_goal(_alife, goal)
		
		_spawn_list.append(_alife)
		
	return _spawn_list
コード例 #15
0
 def attack(self, monsters, monster, messages, game_map):
     weapon = self.get_equipped_item_stats(Weapon)
     if test_for_hit(self.agility + weapon[2], monster.agility):
         dealt_damage = deal_damage(self.damage + weapon[1],
                                    monster.defense)
         messages.append(
             'You attacked {} with {}. You dealt {} damage. The blood is everywhere'
             .format(monster.monster_type, weapon[0], dealt_damage))
         monster.health -= dealt_damage
         if monster.health <= 0:
             messages.append('The {} died in agony.'.format(
                 monster.monster_type))
             game_map[monster.x][monster.y].tile = Cell.EMPTY
             loot = create_item(monster.drop_rarity)
             inventory.add_item(loot, self.inventory, messages)
             self.kill_count += 1
             monsters.remove(monster)
     else:
         messages.append('You missed {}.'.format(monster.monster_type))
コード例 #16
0
ファイル: worldgen.py プロジェクト: athros/Reactor-3
def create_player():
	PLAYER = life.create_life('human',
		name=['Tester','Toaster'],
		position=get_spawn_point(zone_entry_point=True))
	PLAYER['stats'].update(historygen.create_background(life))
	PLAYER['player'] = True
	
	for item in BASE_ITEMS:
		life.add_item_to_inventory(PLAYER, items.create_item(item))

	SETTINGS['controlling'] = PLAYER['id']
	
	_zes_leader = alife.factions.get_faction('ZES')['members'][0]
	_m = missions.create_mission('locate_target', target=_zes_leader)
	_m_id = missions.remember_mission(PLAYER, _m)
	
	missions.change_task_description(PLAYER, _m_id, 1, 'Find ZES outpost, talk to %s' % ' '.join(LIFE[_zes_leader]['name']))
	alife.factions.add_member('Loners', SETTINGS['controlling'])
	lfe.focus_on(LIFE[SETTINGS['controlling']])
	
	return PLAYER
コード例 #17
0
def create_gib(life, icon, size, limb, velocity, color=(tcod.white, None)):
    _gib = {
        'name': 'gib',
        'prefix': 'a',
        'type': 'magazine',
        'icon': icon,
        'flags': ['BLOODY'],
        'description': '%s\'s %s.' % (' '.join(life['name']), limb),
        'size': '%sx1' % size,
        'material': 'flesh',
        'thickness': size,
        'color': color
    }

    _i = items.get_item_from_uid(
        items.create_item('gib', position=life['pos'][:], item=_gib))
    _i['velocity'] = [
        bad_numbers.clip(velocity[0], -3, 3),
        bad_numbers.clip(velocity[1], -3, 3), velocity[2]
    ]

    logging.debug('Created gib.')
コード例 #18
0
ファイル: situations.py プロジェクト: hovatterz/Reactor-3
def drop_cache(item_names):
	while 1:
		_chunk_key = random.choice(WORLD_INFO['chunk_map'].keys())
		_chunk = alife.chunks.get_chunk(_chunk_key)
		
		if _chunk['type'] == 'other':
			break
	
	for item in item_names:
		_pos = random.choice(_chunk['ground'])
		_item = ITEMS[items.create_item(item, position=[_pos[0], _pos[1], 2])]
		
		for life in LIFE.values():
			lfe.memory(life, 'cache_drop', chunk_key=_chunk_key)
			#alife.survival.add_needed_item(life,
			#                               {'pos': _item['pos'][:]},
			#                               satisfy_if=alife.action.make_small_script(function='always'),
			#                               satisfy_callback=alife.action.make_small_script(function='consume'))
			#alife.brain.remember_item(life, _item)
	
	gfx.message('You see something parachuting to the ground.')
	print _chunk['pos']
コード例 #19
0
def create_player():
    PLAYER = life.create_life('human',
                              name=['Tester', 'Toaster'],
                              position=get_spawn_point(zone_entry_point=True))
    PLAYER['stats'].update(historygen.create_background(life))
    PLAYER['player'] = True

    for item in BASE_ITEMS:
        life.add_item_to_inventory(PLAYER, items.create_item(item))

    SETTINGS['controlling'] = PLAYER['id']

    _zes_leader = alife.factions.get_faction('ZES')['members'][0]
    _m = missions.create_mission('locate_target', target=_zes_leader)
    _m_id = missions.remember_mission(PLAYER, _m)

    missions.change_task_description(
        PLAYER, _m_id, 1,
        'Find ZES outpost, talk to %s' % ' '.join(LIFE[_zes_leader]['name']))
    alife.factions.add_member('Loners', SETTINGS['controlling'])
    lfe.focus_on(LIFE[SETTINGS['controlling']])

    return PLAYER
コード例 #20
0
ファイル: crafting.py プロジェクト: athros/Reactor-3
def execute_recipe(life, item, recipe):
	_difficulty = get_recipe_difficulty(life, item, recipe)
	_dice_percentage = numbers.roll(2, 5)/(10.0+_difficulty)
	
	if _dice_percentage >= .75:
		_recipe_quality = 'success'
	elif _dice_percentage >= .5:
		_recipe_quality = 'partial_success'
	else:
		_recipe_quality = 'failure'
	
	if recipe['type'] == 'create_item':
		for create_item in recipe['create_item']:
			if not _recipe_quality in recipe['create_item'][create_item]:
				continue
			
			for i in range(recipe['create_item'][create_item][_recipe_quality]['amount']):
				_created_item = items.create_item(create_item)
				lfe.add_item_to_inventory(life, _created_item)
	
	if _recipe_quality in recipe['strings']:
		gfx.message(recipe['strings'][_recipe_quality])
	else:
		gfx.message('You finish crafting.')
コード例 #21
0
ファイル: worldgen.py プロジェクト: hovatterz/Reactor-3
def create_player():
	PLAYER = life.create_life('human',
		name=['Tester','Toaster'],
		position=get_spawn_point(zone_entry_point=True))
	PLAYER['stats'].update(historygen.create_background(life))
	PLAYER['player'] = True
	
	for item in BASE_ITEMS:
		life.add_item_to_inventory(PLAYER, items.create_item(item))
	
	life.add_item_to_inventory(PLAYER, items.create_item('glock'))
	life.add_item_to_inventory(PLAYER, items.create_item('9x19mm magazine'))
	life.add_item_to_inventory(PLAYER, items.create_item('electric lantern'))
	life.add_item_to_inventory(PLAYER, items.create_item('aspirin'))
	
	for i in range(17):
		life.add_item_to_inventory(PLAYER, items.create_item('9x19mm round'))

	SETTINGS['controlling'] = PLAYER['id']
	
	lfe.focus_on(LIFE[SETTINGS['controlling']])
	
	return PLAYER
コード例 #22
0
ファイル: debug.py プロジェクト: penny64/Reactor-3
def drink():
	items.create_item('soda', position=LIFE[SETTINGS['controlling']]['pos'])
コード例 #23
0
ファイル: debug.py プロジェクト: hovatterz/Reactor-3
def drink():
	items.create_item('soda', position=LIFE[SETTINGS['controlling']]['pos'])
コード例 #24
0
def create_intro_story():
	_i = 2#random.randint(0, 2)
	_player = LIFE[SETTINGS['controlling']]
	
	WORLD_INFO['last_scheme_time'] = WORLD_INFO['ticks']
	
	if _i == 1:
		#events.broadcast([{'text': 'You wake up from a deep sleep.'},
		#           {'text': 'You don\'t remember anything.', 'change_only': True}], 0, glitch=True)
		
		_spawn_items = ['leather backpack', 'M9', '9x19mm magazine']
		
		for i in range(14):
			_spawn_items.append('9x19mm round')
		
		for item_name in _spawn_items:
			lfe.add_item_to_inventory(_player, items.create_item(item_name))
		
		lfe.set_pos(_player, spawns.get_spawn_in_ref('farms'))
		
		#Dead dude
		_dead_guy = lfe.create_life('human', position=spawns.get_spawn_point_around(_player['pos']))
		_dead_guy['dead'] = True
		
		if _player['pos'] == _dead_guy['pos']:
			lfe.set_pos(_dead_guy, [_dead_guy['pos'][0], _dead_guy['pos'][1], _dead_guy['pos'][2]+1])
		
		for i in range(random.randint(15, 20)):
			effects.create_splatter('blood', spawns.get_spawn_point_around(_dead_guy['pos'], area=2), intensity=8)
		
		#Group nearby
		_bandit_group_spawn_chunk = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_player['pos'], min_area=60, area=90))
		_bandit_group = spawns.generate_group('bandit', amount=3, spawn_chunks=[_bandit_group_spawn_chunk])
		
		_friendly_group_spawn_chunk = alife.chunks.get_chunk_key_at(spawns.get_spawn_point_around(_player['pos'], min_area=10, area=20))
		_friendly_group = spawns.generate_group('loner_riflemen', amount=2, spawn_chunks=[_friendly_group_spawn_chunk])
		
		for ai in _bandit_group:
			_target = alife.brain.meet_alife(ai, _player)
			_target['last_seen_time'] = 1
			_target['escaped'] = 1
			_target['last_seen_at'] = _player['pos'][:]
			
			alife.stats.establish_hostile(ai, _player['id'])
			alife.stats.establish_hostile(_player, ai['id'])
			
			for target in _friendly_group:
				_target = alife.brain.meet_alife(ai, target)
				_target['last_seen_time'] = 1
				_target['escaped'] = 1
				_target['last_seen_at'] = target['pos'][:]
				alife.stats.establish_hostile(ai, target['id'])
				
				_group_target = alife.brain.meet_alife(target, ai)
				_group_target['last_seen_time'] = 1
				_group_target['escaped'] = 1
				_group_target['last_seen_at'] = ai['pos'][:]
				alife.stats.establish_hostile(target, ai['id'])
		
		#Wounded running away
		_wounded_guy = _friendly_group[0]
		
		if _wounded_guy['pos'] == _dead_guy['pos']:
			_wounded_guy['pos'][0] -= 1
		
		alife.brain.meet_alife(_wounded_guy, _player)['alignment'] = 'trust'
		alife.brain.meet_alife(_player, _wounded_guy)['alignment'] = 'trust'
		
		#alife.speech.start_dialog(_wounded_guy, _player['id'], 'incoming_targets', force=True)
		alife.memory.create_question(_wounded_guy, _player['id'], 'incoming_targets')
		alife.memory.create_question(_wounded_guy, _player['id'], 'incoming_targets_follow', group_id=_wounded_guy['group'])
	
	elif _i == 2:
		lfe.set_pos(_player, spawns.get_spawn_in_ref('farms'))
コード例 #25
0
def randomize_item_spawns():
    for chunk_key in WORLD_INFO['chunk_map']:
        _chunk = maps.get_chunk(chunk_key)

        if not 'spawn_items' in _chunk['flags']:
            continue

        for item in _chunk['flags']['spawn_items']:
            if random.uniform(0, 1) < item['rarity']:
                continue

            for i in range(item['amount']):
                _rand_pos = random.choice(_chunk['ground'])[:]
                _rand_pos.append(2)
                items.create_item(item['item'], position=_rand_pos)

    return False

    for building in WORLD_INFO['reference_map']['buildings']:
        _chunk_key = random.choice(alife.references.get_reference(building))
        _chunk = maps.get_chunk(_chunk_key)

        if not _chunk['ground']:
            continue

        if random.randint(0, 100) >= 65:
            for i in range(0, 1 + random.randint(0, 3)):
                _rand_pos = random.choice(_chunk['ground'])
                items.create_item('.22 rifle',
                                  position=[_rand_pos[0], _rand_pos[1], 2])
                items.create_item('.22 LR magazine',
                                  position=[_rand_pos[0], _rand_pos[1], 2])

            for i in range(10):
                _rand_pos = random.choice(_chunk['ground'])
                items.create_item('.22 LR cartridge',
                                  position=[_rand_pos[0], _rand_pos[1], 2])
        elif random.randint(0, 100) >= 40:
            _items = ['corn', 'soda']
            for i in range(0, 1 + random.randint(0, 3)):
                _rand_pos = random.choice(_chunk['ground'])
                items.create_item(random.choice(_items),
                                  position=[_rand_pos[0], _rand_pos[1], 2])

        for i in range(0, 1 + random.randint(0, 3)):
            _rand_pos = random.choice(_chunk['ground'])
            items.create_item(random.choice(RECRUIT_ITEMS),
                              position=[_rand_pos[0], _rand_pos[1], 2])
コード例 #26
0
# -*- coding: utf-8 -*-
from __future__ import print_function

from gilded_rose import GildedRose
from items import create_item

if __name__ == "__main__":
    print ("OMGHAI!")
    items = [
        create_item(name="+5 Dexterity Vest", sell_in=10, quality=20),
        create_item(name="Aged Brie", sell_in=2, quality=0),
        create_item(name="Elixir of the Mongoose", sell_in=5, quality=7),
        create_item(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80),
        create_item(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80),
        create_item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20),
        create_item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49),
        create_item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
        create_item(name="Conjured Mana Cake", sell_in=3, quality=6),  # <-- :O
    ]

    days = 2
    import sys
    if len(sys.argv) > 1:
        days = int(sys.argv[1]) + 1
    for day in range(days):
        print("-------- day %s --------" % day)
        print("name, sellIn, quality")
        for item in items:
            print(item)
        print("")
        GildedRose(items).update_items()
コード例 #27
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_foo(self):
     items = [create_item("foo", 0, 0)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual("foo", items[0].name)
コード例 #28
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_sulfuras_no_updates(self):
     items = [create_item("Sulfuras, Hand of Ragnaros", 10, 15)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(10, items[0].sell_in)
     self.assertEqual(15, items[0].quality)
コード例 #29
0
ファイル: debug.py プロジェクト: penny64/Reactor-3
def give(item):
	items.create_item(item, position=LIFE[SETTINGS['controlling']]['pos'])
コード例 #30
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_min_quality(self):
     items = [create_item("foo", 0, 0)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(0, items[0].quality)
コード例 #31
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_max_quality(self):
     items = [create_item("Aged Brie", 0, 50)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(50, items[0].quality)
コード例 #32
0
ファイル: debug.py プロジェクト: hovatterz/Reactor-3
def food():
	items.create_item('corn', position=LIFE[SETTINGS['controlling']]['pos'])
コード例 #33
0
ファイル: debug.py プロジェクト: penny64/Reactor-3
def food():
	items.create_item('corn', position=LIFE[SETTINGS['controlling']]['pos'])
コード例 #34
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_increase_quality(self):
     items = [create_item("foo", 10, 20)]
     items[0].QUALITY_DELTA_PROCESSING_TYPE = QualityDeltaProcessingType.add
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(21, items[0].quality)
コード例 #35
0
ファイル: worldgen.py プロジェクト: athros/Reactor-3
def randomize_item_spawns():
	for chunk_key in WORLD_INFO['chunk_map']:
		_chunk = maps.get_chunk(chunk_key)
		
		if not 'spawn_items' in _chunk['flags']:
			continue
		
		for item in _chunk['flags']['spawn_items']:
			if random.uniform(0, 1)<item['rarity']:
				continue
			
			for i in range(item['amount']):
				_rand_pos = random.choice(_chunk['ground'])[:]
				_rand_pos.append(2)
				items.create_item(item['item'], position=_rand_pos)
		
	return False

	for building in WORLD_INFO['reference_map']['buildings']:
		_chunk_key = random.choice(alife.references.get_reference(building))
		_chunk = maps.get_chunk(_chunk_key)
		
		if not _chunk['ground']:
			continue
		
		if random.randint(0, 100)>=65:
			for i in range(0, 1+random.randint(0, 3)):
				_rand_pos = random.choice(_chunk['ground'])
				items.create_item('.22 rifle', position=[_rand_pos[0], _rand_pos[1], 2])
				items.create_item('.22 LR magazine', position=[_rand_pos[0], _rand_pos[1], 2])
			
			for i in range(10):
				_rand_pos = random.choice(_chunk['ground'])
				items.create_item('.22 LR cartridge', position=[_rand_pos[0], _rand_pos[1], 2])
		elif random.randint(0, 100)>=40:
			_items = ['corn', 'soda']
			for i in range(0, 1+random.randint(0, 3)):
				_rand_pos = random.choice(_chunk['ground'])
				items.create_item(random.choice(_items), position=[_rand_pos[0], _rand_pos[1], 2])
		
		for i in range(0, 1+random.randint(0, 3)):
			_rand_pos = random.choice(_chunk['ground'])
			items.create_item(random.choice(RECRUIT_ITEMS), position=[_rand_pos[0], _rand_pos[1], 2])
コード例 #36
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_conjured_quality_delta(self):
     items = [create_item("Conjured Mana Cake", 10, 15)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(13, items[0].quality)
コード例 #37
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_decrease_quality_once_expired(self):
     items = [create_item("foo", 0, 20)]
     items[0].quality_delta_type = QualityDeltaProcessingType.subtract
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(18, items[0].quality)
コード例 #38
0
 def add():
     name = request.form.get('new_item_name')
     description = request.form.get('new_item_description')
     mongoDB.create_item(collection, board_id, name, description)
     return redirect(url_for('index'))
コード例 #39
0
ファイル: test_gilded_rose.py プロジェクト: tmszk/gildedrose
 def test_decrease_sell_in(self):
     items = [create_item("foo", 10, 20)]
     items[0].quality_delta_type = QualityDeltaProcessingType.subtract
     gilded_rose = GildedRose(items)
     gilded_rose.update_items()
     self.assertEqual(9, items[0].sell_in)
コード例 #40
0
ファイル: debug.py プロジェクト: hovatterz/Reactor-3
def give(item):
	items.create_item(item, position=LIFE[SETTINGS['controlling']]['pos'])