• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python game.load_session函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.game.load_session函数的典型用法代码示例。如果您正苦于以下问题:Python load_session函数的具体用法?Python load_session怎么用?Python load_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load_session函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: saveload

	def saveload(session):
		fd, filename = tempfile.mkstemp()
		os.close(fd)
		assert session.save(savegamename=filename)
		session.end(keep_map=True)
		session =  load_session(filename)
		Scheduler().before_ticking() # late init finish (not ticking already)
		return session
开发者ID:ranjithtanj,项目名称:unknown-horizons,代码行数:8,代码来源:test_load_save.py


示例2: test_ticket_1427

def test_ticket_1427():
	"""Boatbuilder production progress should be saved properly"""

	session, player = new_session()
	settlement, island = settle(session)

	boat_builder = Build(BUILDINGS.BOATBUILDER_CLASS, 35, 20, island, settlement=settlement)(player)
	worldid = boat_builder.worldid

	# Make sure no boards are available
	settlement.get_component(StorageComponent).inventory.alter(RES.BOARDS_ID, -1000)

	bb_storage = boat_builder.get_component(StorageComponent)

	# Add production to use resources
	bb_producer =  boat_builder.get_component(Producer)
	bb_producer.add_production_by_id(PRODUCTIONLINES.HUKER)
	production = bb_producer._productions[PRODUCTIONLINES.HUKER]

	assert production.progress == 0.0

	bb_storage.inventory.alter(RES.TEXTILE_ID, 10)
	bb_storage.inventory.alter(RES.BOARDS_ID, 6)

	production_line = production._prod_line

	# Make sure the boatbuilder consumes everything in his inventory
	session.run(seconds=10)

	# Check if correctly consumed wood
	assert production_line.consumed_res[RES.BOARDS_ID] == -2

	# Save all production process for later
	expected_consumed_res = production_line.consumed_res
	expected_produced_res = production_line.produced_res
	expected_production = production_line.production
	expected_progress = production.progress

	# Make sure the producer used the boards
	assert bb_storage.inventory[RES.BOARDS_ID] == 0

	fd, filename = tempfile.mkstemp()
	os.close(fd)
	assert session.save(savegamename=filename)
	session.end(keep_map=True)

	# Load game
	session = load_session(filename)
	loadedbb = WorldObject.get_object_by_id(worldid)

	production_loaded = loadedbb.get_component(Producer)._productions[PRODUCTIONLINES.HUKER]
	production_line_loaded = production_loaded._prod_line

	# Make sure everything is loaded correctly
	assert expected_consumed_res == production_line_loaded.consumed_res
	assert expected_produced_res == production_line_loaded.produced_res
	assert expected_production == production_line_loaded.production
	assert expected_progress == production_loaded.progress
开发者ID:perher,项目名称:unknown-horizons,代码行数:58,代码来源:test_bugs.py


示例3: test_combat_save_load

def test_combat_save_load():
    """
	create a savegame with combat units and actual combat, then save/load it
	"""

    session, player = new_session()
    (p0, s0), (p1, s1) = setup_combat(session, UNITS.FRIGATE)

    s0_worldid, s1_worldid = s0.worldid, s1.worldid

    session.run(seconds=1)

    # saveload
    fd, filename = tempfile.mkstemp()
    os.close(fd)
    assert session.save(savegamename=filename)
    session.end(keep_map=True)
    session = load_session(filename)

    s0 = WorldObject.get_object_by_id(s0_worldid)
    s1 = WorldObject.get_object_by_id(s1_worldid)

    # fight

    AddEnemyPair(p0, p1).execute(session)

    Attack(s0, s1).execute(session)
    Attack(s1, s0).execute(session)

    session.run(seconds=20)

    # saveload
    fd, filename = tempfile.mkstemp()
    os.close(fd)
    assert session.save(savegamename=filename)
    session.end(keep_map=True)
    session = load_session(filename)

    assert one_dead(s0_worldid, s1_worldid)

    session.end()
开发者ID:ChrisOelmueller,项目名称:unknown-horizons,代码行数:41,代码来源:test_combat.py



注:本文中的tests.game.load_session函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python game.new_session函数代码示例发布时间:2022-05-27
下一篇:
Python gbe_functions.login_as函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap