ruff_hi
Live 4ever! Or die trying
yeah, ok. Got any training available? Its 141mb - does that sound right? eclipse-SDK-3.3.2-win32.zip. Will have to wait until I get home (or work).
Have the current sorting options, plus a few others: Location: Everywhere, Can Promote, and Current Level.
The Current Level will be sorted within it's own pane as well, so you can select all level 5 units.
And I know it's a bit US-centric, but what about changing Sit-Rep to War Room?
Also, I think we should add a panel below the Combat Experience that when you select a unit, will show avaliable promotions to that unit, and when you click on one it actually will promote the unit.
Got any training available?
Its 141mb - does that sound right? eclipse-SDK-3.3.2-win32.zip.
Random Typographer's Note: You only use two spaces after sentence-ending punctuation when using a monospace font like Courier or a typewriter.
L i s t e n b u c k w h e a t - s o m e o f u s l e a r n t t o t y p e o n a n o n - e l e c t r i c t y p e w r i t e r a n d n o w o u r s p a c e b a r t h u m b i s a u t o p r o g r a m e d t o h i t t h e s p a c e b a r t w i c e !Random Typographer's Note: You only use two spaces after sentence-ending punctuation when using a monospace font like Courier or a typewriter.
Well said!I'm guessing this statement goes hand in hand with the other one you made a few days ago about not having anyone to test a MultiPlayer game with?
You will need a Java runtime environment (JRE) to use Eclipse (Java 5 JRE recommended). All downloads are provided under the terms and conditions of the Eclipse Foundation Software User Agreement unless otherwise specified
pPlayer = gc.getPlayer(iPlayer)
[B]eTeam = gc.getPlayer(self.iActivePlayer).getTeam()[/B]
...
for c in range(pPlayer.getNumCities()):
pCity = pPlayer.getCity(c)
if pCity
and not pCity.isNone()
[B]and pCity.isRevealed(eTeam, False)[/B]
and pCity.canTrain(iUnit, False, False):
iUnits.add(iUnit)
break
What is the difference between 'p' and 'e' at the beginning of player and team? I put in the 'p' for pointer. You put in the 'e'? Or are you just messin' with my head?Code:pPlayer = gc.getPlayer(iPlayer) eTeam = gc.getPlayer(self.iActivePlayer).getTeam()
What is the difference between 'p' and 'e' at the beginning of player and team?
The latest BUG-MA has a few issues, and I have some suggestions.
Worst Enemy: Column is too narrow now (threat bar partially inside WE icon) and the header says only "Wo..." Perhaps use a small icon so only the actual leader of the row uses a large icon, and make the header be two rows.
Maybe put the WHEOOH fist next to the threat index bar again since they kinda go hand-in-hand.
Thinking about the "Active Wars" and "Will Declare?" columns, perhaps group them just like the "Strategic Advantages" columns. Put "War" as the main heading, and "Active" and "Willing"/"Would"/"Bribe" or something like that for "Will Declare?" This would make it clear that both columns are about war. I was also thinking maybe reverse the two columns, so "Active" is on the left.
grouping1 = self.stats.getGrouping("loc")
grouping2 = self.stats.getGrouping("type")
## UnitGrouper
## Builds groups of units for use in reporting or screens.
## Copyright (c) 2008 The BUG Mod.
from CvPythonExtensions import *
import BugUtil
# globals
gc = CyGlobalContext()
# Base grouping classes
class Grouper:
"""
Holds all Grouping definitions.
"""
def __init__(self):
self.groupings = []
self.groupingsByKey = {}
def _addGrouping(self, grouping):
grouping.index = len(self.groupings)
self.groupings.append(grouping)
self.groupingsByKey[grouping.key] = grouping
def getGrouping(self, key):
if key in self.groupingsByKey:
return self.groupingsByKey[key]
else:
return None
class Grouping:
"""
Applies a formula to place units into groups.
key: used for sorting groupings; must be in the range [0, 999] inclusive
title: used to display the group
"""
def __init__(self, key, title):
self.index = None
self.key = key
self.title = title
self.groups = {}
def _addGroup(self, group):
self.groups[group.key] = group
def calcGroupKeys(self, unit, player, team):
return None
class Group:
"""
Represents a single group value within a grouping.
key: used for sorting groups; must be in the range [0, 999] inclusive
title: used to display the group
"""
def __init__(self, grouping, key, title):
self.grouping = grouping
self.key = key
self.title = title
def getTitle(self):
return self.title
# Grouping definitions
class UnitTypeGrouping(Grouping):
"""
Groups units by their unit type.
Ex: Warrior, Maceman, Panzer
"""
def __init__(self):
Grouping.__init__(self, "type", "Unit Type")
for i in range(gc.getNumUnitInfos()):
info = gc.getUnitInfo(i)
if info:
self._addGroup(Group(self, i, info.getDescription()))
def calcGroupKeys(self, unit, player, team):
return (unit.getUnitType(),)
class UnitCombatGrouping(Grouping):
"""
Groups units by their combat type.
Ex: None, Melee, Gunpowder, Naval
"""
def __init__(self):
Grouping.__init__(self, "combat", "Combat Type")
self.NONE = 0
self._addGroup(Group(self, self.NONE, "None"))
for i in range(gc.getNumUnitCombatInfos()):
info = gc.getUnitCombatInfo(i)
if info:
self._addGroup(Group(self, i + 1, info.getDescription()))
def calcGroupKeys(self, unit, player, team):
return (gc.getUnitInfo(unit.getUnitType()).getUnitCombatType() + 1,)
class LevelGrouping(Grouping):
"""
Groups units by their level, 1 to MAX_LEVEL (30).
Units over level MAX_LEVEL are put into the MAX_LEVEL group.
"""
def __init__(self):
Grouping.__init__(self, "level", "Level")
self.MAX_LEVEL = 30
for i in range(self.MAX_LEVEL):
self._addGroup(Group(self, i, BugUtil.getText("TXT_KEY_UNIT_GROUPER_LEVEL_GROUP", (str(i),))))
self._addGroup(Group(self, self.MAX_LEVEL, BugUtil.getText("TXT_KEY_UNIT_GROUPER_LEVEL_GROUP", ("%d+" % self.MAX_LEVEL,))))
def calcGroupKeys(self, unit, player, team):
return (max(0, min(unit.getLevel(), self.MAX_LEVEL)),)
class PromotionGrouping(Grouping):
"""
Groups units by their promotions.
Ex: Combat 1, Cover, Tactics
"""
def __init__(self):
Grouping.__init__(self, "promo", "Promotion")
self.NONE = 0
self._addGroup(Group(self, self.NONE, "None"))
for i in range(gc.getNumPromotionInfos()):
info = gc.getPromotionInfo(i)
if info:
self._addGroup(Group(self, i + 1, info.getDescription()))
def calcGroupKeys(self, unit, player, team):
promos = []
for iPromo in range(gc.getNumPromotionInfos()):
if unit.isHasPromotion(iPromo):
promos.append(iPromo + 1)
if not promos:
promos = (self.NONE,)
return promos
class LocationGrouping(Grouping):
"""
Groups units by their location on the map.
Ex: Domestic City, Friendly City, Enemy Territory
"""
def __init__(self):
Grouping.__init__(self, "loc", "Location")
self.DOMESTIC_CITY = 0
self.DOMESTIC_TERRITORY = self.DOMESTIC_CITY + 1
self.TEAM_CITY = self.DOMESTIC_TERRITORY + 1
self.TEAM_TERRITORY = self.TEAM_CITY + 1
self.FRIENDLY_CITY = self.TEAM_TERRITORY + 1
self.FRIENDLY_TERRITORY = self.FRIENDLY_CITY + 1
self.NEUTRAL_TERRITORY = self.FRIENDLY_TERRITORY + 1
self.ENEMY_TERRITORY = self.NEUTRAL_TERRITORY + 1
self.BARBARIAN_TERRITORY = self.ENEMY_TERRITORY + 1
self._addGroup(Group(self, self.DOMESTIC_CITY, "Domestic City"))
self._addGroup(Group(self, self.DOMESTIC_TERRITORY, "Domestic Territory"))
self._addGroup(Group(self, self.TEAM_CITY, "Team City"))
self._addGroup(Group(self, self.TEAM_TERRITORY, "Team Territory"))
self._addGroup(Group(self, self.FRIENDLY_CITY, "Friendly City"))
self._addGroup(Group(self, self.FRIENDLY_TERRITORY, "Friendly Territory"))
self._addGroup(Group(self, self.NEUTRAL_TERRITORY, "Neutral Territory"))
self._addGroup(Group(self, self.ENEMY_TERRITORY, "Enemy Territory"))
self._addGroup(Group(self, self.BARBARIAN_TERRITORY, "Barbarian Territory"))
def calcGroupKeys(self, unit, player, team):
plot = unit.plot()
if not plot or plot.isNone():
return None
if plot.isBarbarian():
return (self.BARBARIAN_TERRITORY,)
teamId = team.getID()
ownerId = plot.getRevealedOwner(teamId, False)
if ownerId == -1:
return (self.NEUTRAL_TERRITORY,)
elif ownerId == player.getID():
if plot.isCity():
return (self.DOMESTIC_CITY,)
else:
return (self.DOMESTIC_TERRITORY,)
else:
owner = gc.getPlayer(ownerId)
ownerTeamId = owner.getTeam()
if ownerTeamId == teamId:
if plot.isCity():
return (self.TEAM_CITY,)
else:
return (self.TEAM_TERRITORY,)
elif team.isAtWar(ownerTeamId):
return (self.ENEMY_TERRITORY,)
else:
if plot.isCity():
return (self.FRIENDLY_CITY,)
else:
return (self.FRIENDLY_TERRITORY,)
class StandardGrouper(Grouper):
def __init__(self):
Grouper.__init__(self)
self._addGrouping(UnitTypeGrouping())
self._addGrouping(UnitCombatGrouping())
self._addGrouping(LevelGrouping())
self._addGrouping(PromotionGrouping())
self._addGrouping(LocationGrouping())
# Classes for tracking stats about groups and units
class GrouperStats:
"""
Holds stats for a set of groupings.
"""
def __init__(self, grouper):
self.grouper = grouper
self.groupings = {}
for grouping in self.grouper.groupings:
self._addGrouping(GroupingStats(grouping))
def _addGrouping(self, grouping):
self.groupings[grouping.grouping.key] = grouping
def processUnit(self, player, team, unit):
stats = UnitStats(unit.getOwner(), unit.getID(), unit)
for grouping in self.groupings.itervalues():
grouping._processUnit(player, team, stats)
return stats
def getGrouping(self, key):
if key in self.groupings:
return self.groupings[key]
else:
return None
def itergroupings(self):
return self.groupings.itervalues()
class GroupingStats:
"""
Holds stats for a grouping.
"""
def __init__(self, grouping):
self.grouping = grouping
self.groups = {}
for group in self.grouping.groups.itervalues():
self._addGroup(GroupStats(group))
def _addGroup(self, group):
self.groups[group.group.key] = group
def _processUnit(self, player, team, unitStats):
keys = self.grouping.calcGroupKeys(unitStats.unit, player, team)
for key in keys:
self.groups[key]._addUnit(unitStats)
def itergroups(self):
return self.groups.itervalues()
class GroupStats:
"""
Holds stats for a group of units.
"""
def __init__(self, group):
self.group = group
self.units = set()
def _addUnit(self, unitStats):
self.units.add(unitStats)
def title(self):
return self.group.title
def size(self):
return len(self.units)
def isEmpty(self):
return self.size() == 0
class UnitStats:
"""
Holds stats about a single unit.
"""
def __init__(self, playerId, unitId, unit):
self.key = (playerId, unitId)
self.unit = unit
def __hash__(self):
return hash(self.key)
def __eq__(self, other):
return self.key == other.key