Package horizons :: Package command :: Module uioptions
[hide private]
[frames] | no frames]

Source Code for Module horizons.command.uioptions

  1  # ################################################### 
  2  # Copyright (C) 2008-2017 The Unknown Horizons Team 
  3  # team@unknown-horizons.org 
  4  # This file is part of Unknown Horizons. 
  5  # 
  6  # Unknown Horizons is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the 
 18  # Free Software Foundation, Inc., 
 19  # 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 20  # ################################################### 
 21   
 22  from horizons.command import GenericCommand, GenericComponentCommand 
 23   
 24   
25 -class SetTaxSetting(GenericCommand):
26 """Sets the taxes for a settlement."""
27 - def __init__(self, settlement, level, new_taxes):
28 super().__init__(settlement, 'set_tax_setting', level, new_taxes)
29 30 31 GenericCommand.allow_network(SetTaxSetting) 32 33
34 -class SetSettlementUpgradePermissions(GenericCommand):
35 """Sets the new upgrade permissions for a level in a settlement."""
36 - def __init__(self, settlement, level, allowed):
37 super().__init__(settlement, 'set_upgrade_permissions', level, allowed)
38 39 40 GenericCommand.allow_network(SetSettlementUpgradePermissions) 41 42
43 -class SetTradeSlot(GenericComponentCommand):
44 """Set status of a trade post's buy/sell slot."""
45 - def __init__(self, trade_post, slot_id, resource_id, selling, limit):
46 super().__init__(trade_post, 'set_slot', slot_id, resource_id, selling, limit)
47 48 49 GenericComponentCommand.allow_network(SetTradeSlot) 50 51
52 -class ClearTradeSlot(GenericComponentCommand):
53 """Clear a trade post's buy/sell slot."""
54 - def __init__(self, trade_post, slot_id):
55 super().__init__(trade_post, 'clear_slot', slot_id, True)
56 57 58 GenericComponentCommand.allow_network(ClearTradeSlot) 59 60
61 -class TransferResource(GenericCommand):
62 """Transfers an amount of a resource from one Storage to another"""
63 - def __init__(self, amount, res_id, transfer_from, transfer_to, signal_errors=False):
64 super().__init__(transfer_from, 'transfer_to_storageholder', amount, res_id, transfer_to.worldid, signal_errors=signal_errors)
65 66 67 GenericCommand.allow_network(TransferResource) 68 69
70 -class SellResource(GenericComponentCommand):
71 """The given trade post attempts to sell the given amount of resource to the ship"""
72 - def __init__(self, trade_post, ship, resource_id, amount):
73 super().__init__(trade_post, 'sell_resource', ship.worldid, resource_id, amount)
74 75 76 GenericComponentCommand.allow_network(SellResource) 77 78
79 -class BuyResource(GenericComponentCommand):
80 """The given trade post attempts to buy the given amount of resource from the ship"""
81 - def __init__(self, trade_post, ship, resource_id, amount):
82 super().__init__(trade_post, 'buy_resource', ship.worldid, resource_id, amount)
83 84 85 GenericComponentCommand.allow_network(BuyResource) 86 87
88 -class RenameObject(GenericComponentCommand):
89 """Rename a NamedComponent"""
90 - def __init__(self, namedcomponent, new_name):
91 super().__init__(namedcomponent, "set_name", new_name)
92 93 94 GenericComponentCommand.allow_network(RenameObject) 95 96
97 -class EquipWeaponFromInventory(GenericCommand):
98 """Equips a weapon to weapon storage from resource inventory"""
99 - def __init__(self, obj, weapon_id, number):
100 super().__init__(obj, "equip_from_inventory", weapon_id, number)
101 102 103 GenericCommand.allow_network(EquipWeaponFromInventory) 104 105
106 -class UnequipWeaponToInventory(GenericCommand):
107 """Equips a weapon to weapon storage from resource inventory"""
108 - def __init__(self, obj, weapon_id, number):
109 super().__init__(obj, "unequip_to_inventory", weapon_id, number)
110 111 112 GenericCommand.allow_network(UnequipWeaponToInventory) 113 114
115 -class RouteConfigCommand(GenericCommand):
116 """Use this for routeconfig actions. 117 There are too many small methods to use single commands. 118 """
119 - def __init__(self, obj, method, *args, **kwargs):
120 super().__init__(obj, method, *args, **kwargs)
121
122 - def _get_object(self):
123 obj = super()._get_object() 124 return obj.route
125 126 127 GenericCommand.allow_network(RouteConfigCommand) 128