Package civquest.core

Examples of civquest.core.TimeRules$StoreTurnTimedMode


   *  shoot.
   *
   * @return an AttackInfo-object as described
   */
  private AttackInfo getNextAttackInfo() {
    TimeRules timeRules = Game.getGame().getTimeRules();

    int minTime = Integer.MAX_VALUE;
    AttackInfo bestAttackInfo = null;

    // CAUTION: Time decreases, so the later a time, the smaller its value
   
    // On the time-axis:
    // 
    //         [                timeOfNextShot              ]
    //         [        dt         ] [       currTime       ]
    // -------|---------------------|------------------------|------------>
    //                     currAttMapObjectTime          startTime

    for (Attacking attacking : allAttackers.keySet()) {
      if (defAttackers.containsKey(attacking)
        && !(attacking.canStillShootAsDefender())) {
        // Our Attacking is a defender, which can't shoot any longer
        continue;
      }
     
      AttMapObjectInfo attMapObjectInfo = allAttackers.get(attacking);
      // the internal time of the current attMapObject when the combat
      // started
      int startTime = attMapObjectInfo.startTime;
      // the internal time the current attMapObject has now
      int currAttMapObjectTime = startTime - currTime;
      // When can the current attacking shoot again?
      int timeOfNextShot = attacking.getTimeOfNextShot();

      int dt = timeOfNextShot - currTime;

      if (attAttackers.containsKey(attacking)
        && !(timeRules.isActionAllowed(dt, currAttMapObjectTime))) {
        continue;
      }

      if (timeOfNextShot < minTime) {
        minTime = timeOfNextShot;
View Full Code Here


  private List<GameChange> computeTimeChanges(Attacking attacker, int timeOfNextShot) {
    List<GameChange> retList = new ArrayList<GameChange>();

    if (attAttackers.containsKey(attacker)) {
      TimeRules timeRules = Game.getGame().getTimeRules();
      int dt = attacker.getTime() - (getAttackerStartTime(attacker) - timeOfNextShot);
      int newTime = timeRules.getTimeAfterAction(dt, attacker.getTime());
      retList.add(SetMapObjectTime.constructSetTimeChange(attacker.getID(), newTime));
    }

    return retList;
  }
View Full Code Here

  */

  private boolean canMoveThisTurn(Game game, Long[] units,
                  int timeForMove) {

    TimeRules timeRules = game.getTimeRules();
    for (Long unit : units) {
      Unit currUnit = game.getMapData().getUnit(unit);
      if (!timeRules.isActionAllowed(timeForMove, currUnit)) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

  }

  private List<GameChange> constructChanges(Game game, Long[] units,
                        Coordinate to,
                        int[] timeForMove) {
    TimeRules timeRules = game.getTimeRules();
    List<GameChange> retList = new ArrayList<GameChange>();
    for (int n = 0; n < units.length; n++) {
      Unit currUnit = game.getMapData().getUnit(units[n]);
      int newTime = timeRules.getTimeAfterAction(timeForMove[n],
                             currUnit);
      retList.add(new MoveUnit(to, units[n], newTime));
    }

    return retList;
View Full Code Here

TOP

Related Classes of civquest.core.TimeRules$StoreTurnTimedMode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.