コード例 #1
0
 @Override
 protected Tracker clone() {
   Tracker ret = (Tracker) super.clone();
   ret.values = new java.util.HashSet<Integer>(this.values);
   ret.unmodifiable = java.util.Collections.unmodifiableSet(ret.values);
   return ret;
 }
コード例 #2
0
    public static final class Tracker
        extends org.rnd.jmagic.engine.Tracker<java.util.Collection<Integer>> {
      private java.util.Set<Integer> values = new java.util.HashSet<Integer>();
      private java.util.Set<Integer> unmodifiable =
          java.util.Collections.unmodifiableSet(this.values);

      @Override
      protected Tracker clone() {
        Tracker ret = (Tracker) super.clone();
        ret.values = new java.util.HashSet<Integer>(this.values);
        ret.unmodifiable = java.util.Collections.unmodifiableSet(ret.values);
        return ret;
      }

      @Override
      protected java.util.Collection<Integer> getValueInternal() {
        return this.unmodifiable;
      }

      @Override
      protected void reset() {
        this.values.clear();
      }

      @Override
      protected boolean match(GameState state, Event event) {
        return event.type == EventType.BECOMES_TARGET;
      }

      @Override
      protected void update(GameState state, Event event) {
        Identified target =
            event
                .parameters
                .get(EventType.Parameter.TARGET)
                .evaluate(state, event.getSource())
                .getOne(Identified.class);
        this.values.add(target.ID);
      }
    }