import net.sf.freecol.server.model.ServerPlayer; //导入方法依赖的package包/类

public void testHorsesLost() {

Game game = ServerTestHelper.startServerGame(getTestMap(true));

Map map = game.getMap();

AIMain aiMain = ServerTestHelper.getServer().getAIMain();

// Create players, settlement and unit

ServerPlayer inca = (ServerPlayer)game.getPlayerByNationId("model.nation.inca");

ServerPlayer dutch = (ServerPlayer)game.getPlayerByNationId("model.nation.dutch");

dutch.exploreMap(true);

Tile settlementTile = map.getTile(2, 1);

FreeColTestCase.IndianSettlementBuilder builder

= new FreeColTestCase.IndianSettlementBuilder(game);

builder.player(inca).settlementTile(settlementTile).build();

IndianSettlement is = settlementTile.getIndianSettlement();

Player.makeContact(inca, dutch);

Tile unitTile = map.getTile(2, 2);

Unit scout = new ServerUnit(game, unitTile, dutch,

scoutType, scoutRole);

assertEquals(scoutRole, scout.getRole());

AIUnit aiUnit = aiMain.getAIUnit(scout);

aiUnit.setMission(null);

assertNotNull("The scout should be an AI unit", aiUnit);

assertEquals("Scout should have the scout role", scoutRole,

scout.getRole());

assertTrue("Scout should be able to speak to chief",

scout.hasAbility(Ability.SPEAK_WITH_CHIEF));

assertEquals("The Inca settlement should be a scouting target", null,

ScoutingMission.invalidReason(aiUnit, is));

assertEquals("The Inca settlement should be found as scouting target",

is, ScoutingMission.findTarget(aiUnit, 10, false));

assertEquals("Scouting mission should be assignable to scout", null,

ScoutingMission.invalidReason(aiUnit));

ScoutingMission mission

= new ScoutingMission(aiMain, aiUnit, is);

assertEquals("Scout should have been assigned the Scouting mission",

mission, aiUnit.getMission());

assertEquals(null, mission.invalidReason());

assertTrue("Scouting mission should be valid",

mission.isValid());

assertEquals("Scouting mission target should be the Inca settlement",

is, mission.getTarget());

// Invalidate the mission by losing the horses.

scout.changeRole(spec().getDefaultRole(), 0);

assertFalse("Scout should not have the scout role",

scout.hasAbility(Ability.SPEAK_WITH_CHIEF));

assertNotNull("Scouting mission should be invalid",

aiUnit.getMission().invalidReason());

assertNotNull("Scouting mission should be impossible for this unit",

ScoutingMission.invalidReason(aiUnit));

// Restore the horses.

scout.changeRole(scoutRole, 1);

assertTrue("Scouting mission should be valid again",

aiUnit.getMission().isValid());

// Complete the mission, should be invalid.

is.setScouted(dutch);

assertFalse("Scouting mission should be invalid lacking target",

aiUnit.getMission().isValid());

// Add an LCR. Mission could become valid again.

Tile lcrTile = map.getTile(2, 3);

lcrTile.addLostCityRumour(new LostCityRumour(game, lcrTile));

assertEquals("Scouting mission should be possible for this unit", null,

ScoutingMission.invalidReason(aiUnit));

assertEquals("The LCR tile should be a scouting target",

lcrTile, ScoutingMission.findTarget(aiUnit, 10, false));

}

java中explore_Java ServerPlayer.exploreMap方法代码示例相关推荐

  1. cdate在java中_Java Calendar.add方法代码示例

    本文整理汇总了Java中java.util.Calendar.add方法的典型用法代码示例.如果您正苦于以下问题:Java Calendar.add方法的具体用法?Java Calendar.add怎 ...

  2. java中setattribute_Java Files.setAttribute方法代码示例

    import java.nio.file.Files; //导入方法依赖的package包/类 @Override public void setFileHiddenAttribute( String ...

  3. JAVA中rootpanel_Java JPanel.setFocusCycleRoot方法代码示例

    import javax.swing.JPanel; //导入方法依赖的package包/类 @Override public void actionPerformed(ActionEvent e) ...

  4. java中mymaps_Java MyLocationStyle.myLocationType方法代码示例

    import com.amap.api.maps.model.MyLocationStyle; //导入方法依赖的package包/类 @Override protected void onCreat ...

  5. java中setDocument_Java ActionItem.setDocumentId方法代码示例

    import org.kuali.rice.kew.actionitem.ActionItem; //导入方法依赖的package包/类 @Test public void testConvertAc ...

  6. java中entry_Java FastMap.Entry方法代码示例

    import javolution.util.FastMap; //导入方法依赖的package包/类 protected void processXmlCAPDialog(XmlCAPDialog ...

  7. java中setcolor_Java XWPFRun.setColor方法代码示例

    import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类 /** * Inserts the given {@link Tem ...

  8. java中settext_Java JCheckBoxMenuItem.setText方法代码示例

    import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类 private void reloadLang() { lang = JLang.g ...

  9. java中setcolor_Java RPr.setColor方法代码示例

    import org.docx4j.wml.RPr; //导入方法依赖的package包/类 public RPr getRPrStyle(ObjectFactory factory, String ...

最新文章

  1. mysql二级索引_mysql——二级索引(辅助索引)
  2. Web前端上万字的知识总结
  3. VS调试时怎么跳过for循环?
  4. 如何查看mysql的gtid_汇总丨MySQL GTID技术点,看这一篇就够了!
  5. java se 1335,1335.逼退法王
  6. 使用Nagios打造专业的业务状态监控
  7. Spring Boot学习总结(13)——Spring Boot加载application.properties配置文件顺序规则
  8. Git修改用户名和邮箱的方法(附Git常用命令)
  9. 《CLR via C#》读书笔记(5)基元类型、引用类型和值类型
  10. OpenResty Redis 安装部署测试SET GET功能
  11. 直线插补和圆弧插补的区别
  12. 修改配色 Mac电脑默认命令行工具(终端\terminal) MacBook Pro MacBook
  13. 计算机网络传输速率单位MB,计算机网络中,传输速率MB/s和Gb/s如何换算?
  14. “我的一剂良药”之开源指北
  15. 经济学论文素材之汇率波动的外汇风险
  16. Timer源代码分析
  17. Acwing LeetCode 题目分类——配套基础课进阶课
  18. Windows系统批量修改文件后缀名/扩展名
  19. openpyxl报错修改:OSError: File contains no valid workbook part
  20. DP:Miking Time(POJ 3616)

热门文章

  1. asp.net 1.1 web.config 讲解
  2. usb-key登录windows+远程桌面
  3. (入门)上传GitHub怎么忽略node_modules
  4. Node中require方法的简单实现
  5. 升级ESXi Host
  6. 利用Swarmkit构建Windows/Linux混合Docker集群
  7. maven搭建ssm框架
  8. 无名岛外贸电商 远程操作linux网站常用命令,整理收集 Linux SSH命令 (
  9. 怎样使用dhcp自动分配IP地址
  10. Windows Phone 7监测网络环境变化