當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。