本文整理汇总了Java中net.sf.freecol.server.model.ServerBuilding类的典型用法代码示例。如果您正苦于以下问题:Java ServerBuilding类的具体用法?Java ServerBuilding怎么用?Java ServerBuilding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerBuilding类属于net.sf.freecol.server.model包,在下文中一共展示了ServerBuilding类的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testLineOfSight
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testLineOfSight() {
Game game = getGame();
Map map = getTestMap();
game.setMap(map);
Colony colony = getStandardColony();
assertEquals(2, colony.getLineOfSight());
BuildingType towerType = new BuildingType("tower", spec());
Modifier modifier = new Modifier(Modifier.LINE_OF_SIGHT_BONUS, 2,
ModifierType.ADDITIVE);
towerType.addModifier(modifier);
Building tower = new ServerBuilding(getGame(), colony, towerType);
colony.addBuilding(tower);
assertEquals(4, colony.getLineOfSight());
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:19,
代码来源:SettlementTest.java
示例2: testFortressRequiresMinimumPopulation
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testFortressRequiresMinimumPopulation() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(7);
colony.addBuilding(new ServerBuilding(game, colony, stockadeType));
colony.addBuilding(new ServerBuilding(game, colony, fortType));
assertEquals(Colony.NoBuildReason.POPULATION_TOO_SMALL,
colony.getNoBuildReason(fortressType, null));
Unit colonist = new ServerUnit(game, colony.getTile(), colony.getOwner(), freeColonistType);
colonist.setLocation(colony);
assertEquals(8, colony.getUnitCount());
assertEquals(Colony.NoBuildReason.NONE,
colony.getNoBuildReason(fortressType, null));
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:18,
代码来源:BuildingTest.java
示例3: testPrintingPressBonus
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testPrintingPressBonus() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(6);
Unit unit = colony.getUnitList().get(0);
Building building = colony.getBuilding(townHallType);
Tile tile = colony.getTile();
for (Unit u : building.getUnitList()) u.setLocation(tile);
int bellProduction = building.getTotalProductionOf(bellsType);
int expectBellProd = 1;
assertEquals("Wrong initial bell production",expectBellProd,bellProduction);
Building printingPress = new ServerBuilding(getGame(), colony, printingPressType);
colony.addBuilding(printingPress);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 1;
assertEquals("Wrong bell production with printing press",expectBellProd,bellProduction);
unit.setLocation(building);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 6; // 1 initial plus 3 from the colonist + 2 from printing press
assertEquals("Wrong final bell production",expectBellProd,bellProduction);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:27,
代码来源:BuildingTest.java
示例4: addSchoolToColony
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
private Building addSchoolToColony(Game game, Colony colony,
SchoolLevel level) {
BuildingType type = null;;
switch (level) {
case SCHOOLHOUSE:
type = schoolType;
break;
case COLLEGE:
type = collegeType;
break;
case UNIVERSITY:
type = universityType;
break;
default:
fail("Setup error, cannot setup school");
}
colony.addBuilding(new ServerBuilding(game, colony, type));
return colony.getBuilding(type);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:20,
代码来源:SchoolTest.java
示例5: testLineOfSight
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testLineOfSight() {
Game game = getGame();
Map map = getTestMap();
game.setMap(map);
Colony colony = getStandardColony();
assertEquals(2, colony.getLineOfSight());
BuildingType towerType = new BuildingType("tower", spec());
Modifier modifier = new Modifier("model.modifier.lineOfSightBonus", 2, Modifier.Type.ADDITIVE);
towerType.addModifier(modifier);
Building tower = new ServerBuilding(getGame(), colony, towerType);
colony.addBuilding(tower);
assertEquals(4, colony.getLineOfSight());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:18,
代码来源:SettlementTest.java
示例6: testPrintingPressBonus
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testPrintingPressBonus() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(6);
Unit unit = colony.getUnitList().get(0);
Building building = colony.getBuilding(townHallType);
int bellProduction = building.getTotalProductionOf(bellsType);
int expectBellProd = 1;
assertEquals("Wrong initial bell production",expectBellProd,bellProduction);
Building printingPress = new ServerBuilding(getGame(), colony, printingPressType);
colony.addBuilding(printingPress);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 1;
assertEquals("Wrong bell production with printing press",expectBellProd,bellProduction);
building.add(unit);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 6; // 1 initial plus 3 from the colonist + 2 from printing press
assertEquals("Wrong final bell production",expectBellProd,bellProduction);
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:25,
代码来源:BuildingTest.java
示例7: testNewspaperBonus
点赞 3
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testNewspaperBonus() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(6);
Unit unit = colony.getUnitList().get(0);
Building building = colony.getBuilding(townHallType);
int bellProduction = building.getTotalProductionOf(bellsType);
int expectBellProd = 1;
assertEquals("Wrong initial bell production",expectBellProd,bellProduction);
Building newspaper = new ServerBuilding(getGame(), colony, newspaperType);
colony.addBuilding(newspaper);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 2;
assertEquals("Wrong bell production with newspaper",expectBellProd,bellProduction);
building.add(unit);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 8; // 1 initial plus 3 from the colonist + 4 from newspaper
assertEquals("Wrong final bell production",expectBellProd,bellProduction);
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:25,
代码来源:BuildingTest.java
示例8: testClearSpecialty
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testClearSpecialty() {
final Game game = ServerTestHelper.startServerGame(getTestMap());
final Map map = game.getMap();
final InGameController igc = ServerTestHelper.getInGameController();
ServerPlayer dutch = (ServerPlayer)game.getPlayerByNationId("model.nation.dutch");
Unit unit = new ServerUnit(game, map.getTile(5, 8), dutch,
hardyPioneerType);
assertTrue("Unit should be a hardy pioneer",
unit.getType() == hardyPioneerType);
// Basic function
igc.clearSpeciality(dutch, unit);
assertTrue("Unit should be cleared of its specialty",
unit.getType() != hardyPioneerType);
// Can not clear speciality while teaching
Colony colony = getStandardColony();
Building school = new ServerBuilding(game, colony, schoolHouseType);
colony.addBuilding(school);
Unit teacher = new ServerUnit(game, map.getTile(5, 8), dutch,
hardyPioneerType);
assertEquals("Unit should be a hardy pioneer",
hardyPioneerType, teacher.getType());
boolean selection = FreeColTestUtils.setStudentSelection(false);
teacher.setLocation(school);
assertNotNull("Teacher should have student", teacher.getStudent());
igc.clearSpeciality(dutch, teacher);
assertEquals("Teacher specialty cannot be cleared",
hardyPioneerType, teacher.getType());
FreeColTestUtils.setStudentSelection(selection);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:37,
代码来源:InGameControllerTest.java
示例9: getToolsBuilder
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
private BuildableType getToolsBuilder(AIColony aiColony) {
Colony colony = aiColony.getColony();
for (BuildableType b : aiColony.getPlannedBuildableTypes()) {
if (colony.canBuild(b)
&& b.getRequiredAmountOf(toolsType) > 0) return b;
if (b instanceof BuildingType) {
colony.addBuilding(new ServerBuilding(colony.getGame(), colony,
(BuildingType)b));
} else if (b instanceof UnitType) {
new ServerUnit(colony.getGame(), colony.getTile(),
colony.getOwner(), (UnitType)b);
}
}
return null;
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:16,
代码来源:AIColonyTest.java
示例10: testCanBuildNext
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testCanBuildNext() {
Game game = getGame();
game.setMap(getTestMap(true));
// First check with a building that can be fully built with a
// normal colony
Colony colony = getStandardColony();
Building warehouse = new ServerBuilding(getGame(), colony, depotType);
colony.addBuilding(warehouse);
assertTrue(warehouse.canBuildNext());
assertNotNull(warehouse.upgrade());
assertTrue(warehouse.canBuildNext());
assertNotNull(warehouse.upgrade());
assertFalse(warehouse.canBuildNext());
assertNull(warehouse.upgrade());
assertFalse(warehouse.canBuildNext());
// Check whether population restrictions work
// Colony smallColony = getStandardColony(1);
//
// Colony largeColony = getStandardColony(6);
// ...
// Check whether founding fathers work
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:29,
代码来源:BuildingTest.java
示例11: testFortRequiresMinimumPopulation
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testFortRequiresMinimumPopulation() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(2);
assertEquals(Colony.NoBuildReason.POPULATION_TOO_SMALL,
colony.getNoBuildReason(fortType, null));
Unit colonist = new ServerUnit(game, colony.getTile(), colony.getOwner(), freeColonistType);
colonist.setLocation(colony);
colony.addBuilding(new ServerBuilding(game, colony, stockadeType));
assertEquals(Colony.NoBuildReason.NONE,
colony.getNoBuildReason(fortType, null));
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:16,
代码来源:BuildingTest.java
示例12: testNewspaperBonus
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testNewspaperBonus() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(6);
Unit unit = colony.getUnitList().get(0);
Building building = colony.getBuilding(townHallType);
clearWorkLocation(building);
int bellProduction = building.getTotalProductionOf(bellsType);
int expectBellProd = 1;
assertEquals("Wrong initial bell production", expectBellProd,
bellProduction);
Building newspaper = new ServerBuilding(getGame(), colony,
newspaperType);
colony.addBuilding(newspaper);
colony.invalidateCache();
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 2;
assertEquals("Wrong bell production with newspaper", expectBellProd,
bellProduction);
unit.setLocation(building);
bellProduction = building.getTotalProductionOf(bellsType);
expectBellProd = 8; // 1 initial plus 3 from the colonist + 4 from newspaper
assertEquals("Wrong final bell production", expectBellProd,
bellProduction);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:31,
代码来源:BuildingTest.java
示例13: testWagonTrainLimit
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testWagonTrainLimit() {
Game game = getStandardGame();
Map map = getTestMap();
game.setMap(map);
Player dutch = game.getPlayerByNationId("model.nation.dutch");
Colony colony = getStandardColony(3);
Building armory = new ServerBuilding(getGame(), colony, spec().getBuildingType("model.building.armory"));
colony.addBuilding(armory);
UnitType wagonTrain = spec().getUnitType("model.unit.wagonTrain");
UnitType artillery = spec().getUnitType("model.unit.artillery");
Limit wagonTrainLimit = wagonTrain.getLimits().get(0);
assertTrue(colony.canBuild(artillery));
assertFalse(wagonTrainLimit.getLeftHandSide().appliesTo(artillery));
assertTrue(wagonTrainLimit.evaluate(colony));
assertTrue(colony.canBuild(wagonTrain));
Unit wagon = new ServerUnit(game, colony.getTile(), dutch, wagonTrain);
assertNotNull(wagon);
assertEquals(Colony.NoBuildReason.LIMIT_EXCEEDED,
colony.getNoBuildReason(wagonTrain, null));
assertFalse(wagonTrainLimit.evaluate(colony));
assertFalse(colony.canBuild(wagonTrain));
assertTrue(colony.canBuild(artillery));
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:30,
代码来源:LimitTest.java
示例14: testClearSpecialty
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testClearSpecialty() {
Map map = getTestMap();
Game game = ServerTestHelper.startServerGame(map);
InGameController igc = ServerTestHelper.getInGameController();
Player dutch = game.getPlayer("model.nation.dutch");
Unit unit = new ServerUnit(game, map.getTile(5, 8), dutch, hardyPioneerType);
assertTrue("Unit should be a hardy pioneer",
unit.getType() == hardyPioneerType);
// Basic function
igc.clearSpeciality((ServerPlayer) dutch, unit);
assertTrue("Unit should be cleared of its specialty",
unit.getType() != hardyPioneerType);
// Can not clear speciality while teaching
Colony colony = getStandardColony();
Building school = new ServerBuilding(game, colony, schoolHouseType);
colony.addBuilding(school);
Unit teacher = new ServerUnit(game, school, colony.getOwner(),
hardyPioneerType);
assertEquals("Unit should be a hardy pioneer",
hardyPioneerType, teacher.getType());
igc.clearSpeciality((ServerPlayer) dutch, teacher);
assertEquals("Teacher specialty cannot be cleared",
hardyPioneerType, teacher.getType());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:28,
代码来源:InGameControllerTest.java
示例15: getToolsBuilder
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
private BuildableType getToolsBuilder(AIColony aiColony) {
Colony colony = aiColony.getColony();
for (BuildableType b : aiColony.getColonyPlan().getBuildableTypes()) {
if (colony.canBuild(b)
&& b.getRequiredAmountOf(toolsType) > 0) return b;
if (b instanceof BuildingType) {
colony.addBuilding(new ServerBuilding(colony.getGame(), colony,
(BuildingType)b));
} else if (b instanceof UnitType) {
new ServerUnit(colony.getGame(), colony.getTile(),
colony.getOwner(), (UnitType)b);
}
}
return null;
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:16,
代码来源:AIColonyTest.java
示例16: testCanBuildNext
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testCanBuildNext() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony();
// First check with a building that can be fully built with a
// normal colony
Building warehouse = new ServerBuilding(getGame(), colony, depotType);
colony.addBuilding(warehouse);
assertTrue(warehouse.canBuildNext());
warehouse.upgrade();
assertTrue(warehouse.canBuildNext());
warehouse.upgrade();
assertFalse(warehouse.canBuildNext());
assertFalse(warehouse.upgrade());
assertFalse(warehouse.canBuildNext());
// Check whether population restrictions work
// Colony smallColony = getStandardColony(1);
//
// Colony largeColony = getStandardColony(6);
// ...
// Check whether founding fathers work
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:30,
代码来源:BuildingTest.java
示例17: testFortRequiresMinimumPopulation
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testFortRequiresMinimumPopulation() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(2);
assertEquals(Colony.NoBuildReason.POPULATION_TOO_SMALL, colony.getNoBuildReason(fortType));
Unit colonist = new ServerUnit(game, colony.getTile(), colony.getOwner(), freeColonistType);
colonist.setLocation(colony);
colony.addBuilding(new ServerBuilding(game, colony, stockadeType));
assertEquals(Colony.NoBuildReason.NONE, colony.getNoBuildReason(fortType));
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:13,
代码来源:BuildingTest.java
示例18: testFortressRequiresMinimumPopulation
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testFortressRequiresMinimumPopulation() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(7);
colony.addBuilding(new ServerBuilding(game, colony, stockadeType));
colony.addBuilding(new ServerBuilding(game, colony, fortType));
assertEquals(Colony.NoBuildReason.POPULATION_TOO_SMALL, colony.getNoBuildReason(fortressType));
Unit colonist = new ServerUnit(game, colony.getTile(), colony.getOwner(), freeColonistType);
colonist.setLocation(colony);
assertEquals(8, colony.getUnitCount());
assertEquals(Colony.NoBuildReason.NONE, colony.getNoBuildReason(fortressType));
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:16,
代码来源:BuildingTest.java
示例19: testWagonTrainLimit
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testWagonTrainLimit() {
Game game = getStandardGame();
Player dutch = game.getPlayer("model.nation.dutch");
Map map = getTestMap();
game.setMap(map);
Colony colony = getStandardColony(3);
Building armory = new ServerBuilding(getGame(), colony, spec().getBuildingType("model.building.armory"));
colony.addBuilding(armory);
UnitType wagonTrain = spec().getUnitType("model.unit.wagonTrain");
UnitType artillery = spec().getUnitType("model.unit.artillery");
Limit wagonTrainLimit = wagonTrain.getLimits().get(0);
assertTrue(colony.canBuild(artillery));
assertFalse(wagonTrainLimit.getLeftHandSide().appliesTo(artillery));
assertTrue(wagonTrainLimit.evaluate(colony));
assertTrue(colony.canBuild(wagonTrain));
@SuppressWarnings("unused")
Unit wagon = new ServerUnit(game, colony.getTile(), dutch, wagonTrain);
assertEquals(Colony.NoBuildReason.LIMIT_EXCEEDED, colony.getNoBuildReason(wagonTrain));
assertFalse(wagonTrainLimit.evaluate(colony));
assertFalse(colony.canBuild(wagonTrain));
assertTrue(colony.canBuild(artillery));
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:31,
代码来源:LimitTest.java
示例20: testConsumers
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testConsumers() {
Game game = getGame();
game.setMap(getTestMap());
Colony colony = getStandardColony(3);
int units = colony.getUnitCount();
int buildings = colony.getBuildings().size();
List<Consumer> consumers = colony.getConsumers();
// units come first
for (int index = 0; index < units; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Unit);
}
// buildings come next
for (int index = units; index < units + buildings; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Building);
}
// build and population queues come last
for (int index = units + buildings; index < units + buildings + 2; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof BuildQueue);
}
Building country = colony.getBuilding(countryType);
assertTrue(consumers.contains(country));
Building depot = colony.getBuilding(depotType);
assertTrue(consumers.contains(depot));
int countryIndex = consumers.indexOf(country);
int depotIndex = consumers.indexOf(depot);
assertTrue(countryIndex >= 0);
assertTrue(depotIndex >= 0);
assertTrue("Priority of depot should be higher than that of country",
depotIndex < countryIndex);
BuildingType armoryType = spec().getBuildingType("model.building.armory");
Building armory = new ServerBuilding(getGame(), colony, armoryType);
colony.addBuilding(armory);
consumers = colony.getConsumers();
// units come first
for (int index = 0; index < units; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Unit);
}
int offset = units + buildings;
// buildings come next
for (int index = units; index < offset; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Building);
}
// build queue comes last
assertTrue(consumers.get(offset).toString(),
consumers.get(offset) instanceof BuildQueue);
// armory has a lower priority than the build queue
assertTrue(consumers.get(offset + 1).toString(),
consumers.get(offset + 1) instanceof Building);
assertEquals(armoryType, ((Building) consumers.get(offset + 1)).getType());
// population queue comes last
assertTrue(consumers.get(offset + 2).toString(),
consumers.get(offset + 2) instanceof BuildQueue);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:67,
代码来源:ColonyProductionTest.java
示例21: testToolsMusketProduction
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testToolsMusketProduction() {
// Test the interaction between tools and muskets
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(8);
Tile tile = colony.getTile();
List<Unit> units = colony.getUnitList();
assertEquals(8, units.size());
// Make sure there are enough goods to get started, and make
// sure enough bells and food are being produced.
// colony.addGoods(spec().getGoodsType("model.goods.food"), 100);
colony.addGoods(bellsType, Colony.LIBERTY_PER_REBEL * 3);
units.get(0).setLocation(tile);
units.get(1).setLocation(tile);
units.get(2).setLocation(tile);
units.get(3).setLocation(tile);
assertTrue(colony.getColonyTile(tile.getNeighbourOrNull(Direction.N))
.setWorkFor(units.get(4)));
assertTrue(colony.getColonyTile(tile.getNeighbourOrNull(Direction.E))
.setWorkFor(units.get(5)));
assertTrue(colony.getColonyTile(tile.getNeighbourOrNull(Direction.S))
.setWorkFor(units.get(6)));
assertTrue(colony.getBuilding(townHallType)
.setWorkFor(units.get(7)));
Building smithy = colony.getBuilding(blacksmithHouseType);
assertFalse(smithy.setWorkFor(units.get(0)));
colony.addGoods(oreType, 50); // Add ore so the smithy becomes viable
assertTrue(smithy.setWorkFor(units.get(0)));
assertTrue(smithy.setWorkFor(units.get(1)));
Building armory = new ServerBuilding(game, colony, armoryType);
colony.addBuilding(armory);
colony.invalidateCache();
assertTrue(armory.setWorkFor(units.get(2)));
assertTrue(armory.setWorkFor(units.get(3)));
assertEquals(toolsType, units.get(0).getWorkType());
assertEquals(toolsType, units.get(1).getWorkType());
assertEquals(musketsType, units.get(2).getWorkType());
assertEquals(musketsType, units.get(3).getWorkType());
assertEquals(6, smithy.getTotalProductionOf(toolsType));
assertEquals(6, armory.getTotalProductionOf(musketsType));
// Upgrade the buildings
smithy.upgrade();
armory.upgrade();
colony.invalidateCache();
assertEquals(toolsType, units.get(0).getWorkType());
assertEquals(toolsType, units.get(1).getWorkType());
assertEquals(musketsType, units.get(2).getWorkType());
assertEquals(musketsType, units.get(3).getWorkType());
assertEquals(12, smithy.getTotalProductionOf(toolsType));
assertEquals(12, armory.getTotalProductionOf(musketsType));
// Upgrade to factory level
colony.getOwner().addFather(spec()
.getFoundingFather("model.foundingFather.adamSmith"));
smithy.upgrade();
armory.upgrade();
colony.invalidateCache();
assertEquals(toolsType, units.get(0).getWorkType());
assertEquals(toolsType, units.get(1).getWorkType());
assertEquals(musketsType, units.get(2).getWorkType());
assertEquals(musketsType, units.get(3).getWorkType());
assertEquals(18, smithy.getTotalProductionOf(toolsType));
//assertEquals("According to bug report #3430371, the arsenal does not enjoy "
// + "the usual factory level production bonus of 50%",
// 12, armory.getTotalProductionOf(musketsType));
// #3430371 has been reverted until we can work out what arsenal
// did that differed from magazine
assertEquals(18, armory.getTotalProductionOf(musketsType));
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:79,
代码来源:BuildingTest.java
示例22: testEducationOption
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testEducationOption() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(5);
Iterator<Unit> units = colony.getUnitList().iterator();
Unit lumberJack = units.next();
lumberJack.setType(expertLumberJackType);
Unit criminal1 = units.next();
criminal1.setType(pettyCriminalType);
Unit criminal2 = units.next();
criminal2.setType(pettyCriminalType);
Unit colonist1 = units.next();
colonist1.setType(freeColonistType);
Unit colonist2 = units.next();
colonist2.setType(freeColonistType);
boolean selection = FreeColTestUtils.setStudentSelection(true);
colony.addBuilding(new ServerBuilding(getGame(), colony, schoolType));
Building school = colony.getBuilding(schoolType);
assertTrue(school.canTeach());
assertTrue(colony.canTrain(lumberJack));
lumberJack.setLocation(school);
colonist1.changeWorkType(cotton);
colonist2.changeWorkType(lumber);
assertEquals(cotton, colonist1.getWorkType());
assertEquals(expertLumberJackType.getExpertProduction(), colonist2.getWorkType());
assertEquals(null, colony.findStudent(lumberJack));
lumberJack.setStudent(null);
colonist2.setTeacher(null);
FreeColTestUtils.setStudentSelection(false);
criminal1.changeWorkType(cotton);
criminal2.changeWorkType(lumber);
assertEquals(criminal2, colony.findStudent(lumberJack));
FreeColTestUtils.setStudentSelection(selection);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:44,
代码来源:SchoolTest.java
示例23: addBuildings
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
/**
* Debug action to add buildings to the user colonies.
*
* Called from the debug menu.
*
* @param freeColClient The <code>FreeColClient</code> in effect.
* @param buildingTitle A label for the choice dialog.
*/
public static void addBuildings(final FreeColClient freeColClient,
String buildingTitle) {
final FreeColServer server = freeColClient.getFreeColServer();
final Game game = freeColClient.getGame();
final GUI gui = freeColClient.getGUI();
final Player player = freeColClient.getMyPlayer();
List<ChoiceItem<BuildingType>> buildings
= new ArrayList<ChoiceItem<BuildingType>>();
for (BuildingType b : game.getSpecification().getBuildingTypeList()) {
String msg = Messages.message(b.toString() + ".name");
buildings.add(new ChoiceItem<BuildingType>(msg, b));
}
BuildingType buildingType
= gui.showChoiceDialog(null, buildingTitle, "Cancel", buildings);
if (buildingType == null) return;
final Game sGame = server.getGame();
final BuildingType sBuildingType = server.getSpecification()
.getBuildingType(buildingType.getId());
final Player sPlayer = sGame.getFreeColGameObject(player.getId(),
Player.class);
List<String> results = new ArrayList<String>();
int fails = 0;
for (Colony sColony : sPlayer.getColonies()) {
Colony.NoBuildReason reason = sColony.getNoBuildReason(sBuildingType);
results.add(sColony.getName() + ": " + reason.toString());
if (reason == Colony.NoBuildReason.NONE) {
Building sBuilding = new ServerBuilding(sGame, sColony,
sBuildingType);
sColony.addBuilding(sBuilding);
} else {
fails++;
}
}
gui.showInformationMessage(Utils.join(", ", results));
if (fails < sPlayer.getNumberOfSettlements()) {
// Brutally resynchronize
freeColClient.getConnectController().reconnect();
}
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:50,
代码来源:DebugUtils.java
示例24: testConsumers
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testConsumers() {
Game game = getGame();
game.setMap(getTestMap());
Colony colony = getStandardColony(3);
int units = colony.getUnitCount();
int buildings = colony.getBuildings().size();
List<Consumer> consumers = colony.getConsumers();
// units come first
for (int index = 0; index < units; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Unit);
}
// buildings come next
for (int index = units; index < units + buildings; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Building);
}
// build and population queues come last
for (int index = units + buildings; index < units + buildings + 2; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof BuildQueue);
}
Building country = colony.getBuilding(countryType);
assertTrue(consumers.contains(country));
Building depot = colony.getBuilding(depotType);
assertTrue(consumers.contains(depot));
int countryIndex = consumers.indexOf(country);
int depotIndex = consumers.indexOf(depot);
assertTrue(countryIndex >= 0);
assertTrue(depotIndex >= 0);
assertTrue("Priority of depot should be higher than that of country",
depotIndex < countryIndex);
BuildingType armoryType = spec().getBuildingType("model.building.armory");
Building armory = new ServerBuilding(getGame(), colony, armoryType);
colony.addBuilding(armory);
consumers = colony.getConsumers();
// units come first
for (int index = 0; index < units; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Unit);
}
int offset = units + buildings;
// buildings come next
for (int index = units; index < offset; index++) {
assertTrue(consumers.get(index).toString(),
consumers.get(index) instanceof Building);
}
// build queue comes last
assertTrue(consumers.get(offset).toString(),
consumers.get(offset) instanceof BuildQueue);
// armory has a lower priority than the build queue
assertTrue(consumers.get(offset + 1).toString(),
consumers.get(offset + 1) instanceof Building);
assertEquals(armoryType, ((Building) consumers.get(offset + 1)).getType());
// population queue comes last
assertTrue(consumers.get(offset + 2).toString(),
consumers.get(offset + 2) instanceof BuildQueue);
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:71,
代码来源:ColonyProductionTest.java
示例25: testToolsMusketProduction
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testToolsMusketProduction() {
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(8);
List<Unit> units = colony.getUnitList();
// make sure there are enough goods to get started
//colony.addGoods(spec().getGoodsType("model.goods.food"), 100);
colony.addGoods(spec().getGoodsType("model.goods.ore"), 100);
// make sure no penalties apply
colony.addGoods(spec().getGoodsType("model.goods.bells"),
Colony.LIBERTY_PER_REBEL * 3);
colony.updatePopulation(0);
Building smithy = colony.getBuilding(blacksmithType);
smithy.add(units.get(0));
smithy.add(units.get(1));
Building armory = new ServerBuilding(game, colony, armoryType);
colony.addBuilding(armory);
armory.add(units.get(2));
armory.add(units.get(3));
assertEquals(3, smithy.getType().getBasicProduction());
assertEquals(6, smithy.getTotalProductionOf(toolsType));
assertEquals(3, armory.getType().getBasicProduction());
assertEquals(6, armory.getTotalProductionOf(musketsType));
smithy.upgrade();
armory.upgrade();
assertEquals(6, smithy.getType().getBasicProduction());
assertEquals(12, smithy.getTotalProductionOf(toolsType));
assertEquals(6, armory.getType().getBasicProduction());
assertEquals(12, armory.getTotalProductionOf(musketsType));
// make sure we can build factory level buildings
colony.getOwner().addFather(spec().getFoundingFather("model.foundingFather.adamSmith"));
smithy.upgrade();
armory.upgrade();
assertEquals(6, smithy.getType().getBasicProduction());
assertEquals(18, smithy.getTotalProductionOf(toolsType));
assertEquals(6, armory.getType().getBasicProduction());
//assertEquals("According to bug report #3430371, the arsenal does not enjoy "
// + "the usual factory level production bonus of 50%",
// 12, armory.getTotalProductionOf(musketsType));
// #3430371 has been reverted until we can work out what arsenal
// did that differed from magazine
assertEquals(18, armory.getTotalProductionOf(musketsType));
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:52,
代码来源:BuildingTest.java
示例26: testEducationOption
点赞 2
import net.sf.freecol.server.model.ServerBuilding; //导入依赖的package包/类
public void testEducationOption() {
GoodsType lumber = spec().getGoodsType("model.goods.lumber");
GoodsType cotton = spec().getGoodsType("model.goods.cotton");
Game game = getGame();
game.setMap(getTestMap(true));
Colony colony = getStandardColony(5);
Iterator<Unit> units = colony.getUnitIterator();
Unit lumberJack = units.next();
lumberJack.setType(expertLumberJackType);
Unit criminal1 = units.next();
criminal1.setType(pettyCriminalType);
Unit criminal2 = units.next();
criminal2.setType(pettyCriminalType);
Unit colonist1 = units.next();
colonist1.setType(freeColonistType);
Unit colonist2 = units.next();
colonist2.setType(freeColonistType);
colony.addBuilding(new ServerBuilding(getGame(), colony, schoolType));
Building school = colony.getBuilding(schoolType);
assertTrue(school.canTeach());
assertTrue(colony.canTrain(lumberJack));
assertTrue(spec().getBoolean(GameOptions.ALLOW_STUDENT_SELECTION));
lumberJack.setLocation(school);
colonist1.setWorkType(cotton);
colonist2.setWorkType(lumber);
assertEquals(cotton, colonist1.getWorkType());
assertEquals(expertLumberJackType.getExpertProduction(), colonist2.getWorkType());
assertEquals(null, colony.findStudent(lumberJack));
lumberJack.setStudent(null);
colonist2.setTeacher(null);
spec().getBooleanOption(GameOptions.ALLOW_STUDENT_SELECTION).setValue(false);
criminal1.setWorkType(cotton);
criminal2.setWorkType(lumber);
assertEquals(criminal2, colony.findStudent(lumberJack));
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:45,
代码来源:SchoolTest.java