当前位置: 首页>>代码示例>>Python>>正文


Python Command.allow_network方法代码示例

本文整理汇总了Python中horizons.command.Command.allow_network方法的典型用法代码示例。如果您正苦于以下问题:Python Command.allow_network方法的具体用法?Python Command.allow_network怎么用?Python Command.allow_network使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizons.command.Command的用法示例。


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

示例1: _

# 需要导入模块: from horizons.command import Command [as 别名]
# 或者: from horizons.command.Command import allow_network [as 别名]
			path = SavegameManager.create_multiplayersave_filename(self.name)
		except RuntimeError as e:
			headline = _("Invalid filename")
			msg = _("Received an invalid filename for a save command.")
			session.gui.show_error_popup(headline, msg, unicode(e))
			return

		self.log.debug("SaveCommand: save to %s", path)

		success = session._do_save(path)
		if success:
			session.ingame_gui.message_widget.add(point=None, string_id='SAVED_GAME') # TODO: distinguish auto/quick/normal
		else:
			session.gui.show_popup(_('Error'), _('Failed to save.'))

Command.allow_network(SaveCommand)



class SpeedUpCommand(Command):
	"""Used to change the game speed"""

	def __call__(self, issuer):
		session = issuer.session
		session.speed_up()

Command.allow_network(SpeedUpCommand)

class SpeedDownCommand(Command):
	"""Used to change the game speed"""
开发者ID:ChrisOelmueller,项目名称:unknown-horizons,代码行数:32,代码来源:game.py

示例2: GenericDiplomacyCommand

# 需要导入模块: from horizons.command import Command [as 别名]
# 或者: from horizons.command.Command import allow_network [as 别名]
from horizons.util.worldobject import WorldObject
from horizons.command import Command

class GenericDiplomacyCommand(Command):
	def __init__(self, a, b):
		self.player1_id = a.worldid
		self.player2_id = b.worldid

class AddAllyPair(GenericDiplomacyCommand):
	def __call__(self, issuer):
		player1 = WorldObject.get_object_by_id(self.player1_id)
		player2 = WorldObject.get_object_by_id(self.player2_id)
		player1.session.world.diplomacy.add_ally_pair(player1, player2)

Command.allow_network(AddAllyPair)

class AddEnemyPair(GenericDiplomacyCommand):
	def __call__(self, issuer):
		player1 = WorldObject.get_object_by_id(self.player1_id)
		player2 = WorldObject.get_object_by_id(self.player2_id)
		player1.session.world.diplomacy.add_enemy_pair(player1, player2)

Command.allow_network(AddEnemyPair)

class AddNeutralPair(GenericDiplomacyCommand):
	def __call__(self, issuer):
		player1 = WorldObject.get_object_by_id(self.player1_id)
		player2 = WorldObject.get_object_by_id(self.player2_id)
		player1.session.world.diplomacy.add_neutral_pair(player1, player2)
开发者ID:ErwinJunge,项目名称:unknown-horizons,代码行数:31,代码来源:diplomacy.py

示例3: PlaySound

# 需要导入模块: from horizons.command import Command [as 别名]
# 或者: from horizons.command.Command import allow_network [as 别名]
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.ambientsound import AmbientSound
from horizons.util import Point
from horizons.command import Command

class PlaySound(Command):
	"""Command class that plays the build sound. This has been moved to a separate
	class, in order to be able to play only one sound for 20 buildings(like a group of
	trees)
	@param sound: sound id that is to be played
	@param position: tuple of int coordinates where the sound is to be played."""

	def __init__(self, sound, position=None, **trash):
		self.sound = sound
		self.position = position

	def __call__(self, issuer):
		"""Execute the command
		@param issuer: the issuer of the command
		"""
		if self.position is None:
			AmbientSound.play_special(self.sound)
		else:
			AmbientSound.play_special(self.sound, Point(self.position[0], self.position[1]))

Command.allow_network(PlaySound)
开发者ID:mihaibivol,项目名称:unknown-horizons,代码行数:32,代码来源:sounds.py

示例4: return

# 需要导入模块: from horizons.command import Command [as 别名]
# 或者: from horizons.command.Command import allow_network [as 别名]
		for resource in needed_res:
			# check player, ship and settlement inventory
			available_res = 0
			# player
			available_res += issuer.get_component(StorageComponent).inventory[resource] if resource == RES.GOLD else 0
			# ship or settlement
			for res_source in res_sources:
				if res_source is not None:
					available_res += res_source.get_component(StorageComponent).inventory[resource]

			if (available_res - reserved_res[resource]) < needed_res[resource]:
				return (False, resource)
		return (True, None)

Command.allow_network(Build)
Command.allow_network(set)

class Tear(Command):
	"""Command class that tears an object."""
	def __init__(self, building):
		"""Create the command
		@param building: building that is to be teared.
		"""
		self.building = building.worldid

	def __call__(self, issuer):
		"""Execute the command
		@param issuer: the issuer of the command
		"""
		try:
开发者ID:MasterofJOKers,项目名称:unknown-horizons,代码行数:32,代码来源:building.py

示例5: Chat

# 需要导入模块: from horizons.command import Command [as 别名]
# 或者: from horizons.command.Command import allow_network [as 别名]
# This file is part of Unknown Horizons.
#
# Unknown Horizons is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.command import Command


class Chat(Command):
    def __init__(self, message):
        self.message = unicode(message)

    def __call__(self, issuer):
        issuer.session.ingame_gui.message_widget.add_chat(player=issuer.name, messagetext=self.message)


Command.allow_network(Chat)
开发者ID:unknown-horizons,项目名称:unknown-horizons,代码行数:32,代码来源:misc.py

示例6: ObjectUpgrade

# 需要导入模块: from horizons.command import Command [as 别名]
# 或者: from horizons.command.Command import allow_network [as 别名]
see:
http://wiki.unknown-horizons.org/index.php/Upgradeable_production_data
http://wiki.unknown-horizons.org/index.php/DD/Buildings/Building_upgrades
"""


class ObjectUpgrade(Command):
	def __init__(self):
		# TODO
		pass

	def __call__(self, issuer):
		# TODO
		pass

Command.allow_network(ObjectUpgrade)

def upgrade_production_time(obj, factor):
	"""
	"""
	assert isinstance(factor, float)
	obj.alter_production_time(factor)

def add_collector(obj, collector_class, number):
	"""
	"""
	for i in xrange(0, number):
		obj.add_collector(collector_class)

def change_runnning_costs(obj, costs_diff):
	"""
开发者ID:aviler,项目名称:unknown-horizons,代码行数:33,代码来源:objectupgrades.py


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