Example #1
0
 @Test
 public void canExecute_test() {
   when(player.getRace()).thenReturn(RaceTypes.Terran);
   assertFalse(action.canExecute(unit, act));
   when(player.getRace()).thenReturn(RaceTypes.Zerg);
   assertTrue(action.canExecute(unit, act));
 }
Example #2
0
  @Test
  public void isValid_test() {
    StarcraftAction spyAction = Mockito.spy(action);

    when(spyAction.getUnitType("Zerg Hydralisk")).thenReturn(unitType);

    params.removeLast();
    assertTrue(spyAction.isValid(act));
    params.add(new Numeral(2));

    assertFalse(action.isValid(act));
    params.remove(1);
    assertFalse(action.isValid(act));
    params.set(0, new Numeral(1));
    assertFalse(action.isValid(act));
    params.set(0, new Identifier("Hero Mojo"));
    assertFalse(action.isValid(act));
  }
  // Override Behavior's stimulus method to handle the event
  public void processStimulus(Enumeration criteria) {

    // NOTE: This assumes 3 objects.  It should be generalized to
    // "n" objects.

    double val = alpha.value();
    if (val < 0.5) {
      double a = val * 2.0;
      weights[0] = 1.0 - a;
      weights[1] = a;
      weights[2] = 0.0;
    } else {
      double a = (val - 0.5) * 2.0;
      weights[0] = 0.0;
      weights[1] = 1.0f - a;
      weights[2] = a;
    }

    morph.setWeights(weights);

    // Set wakeup criteria for next time
    wakeupOn(w);
  }
Example #4
0
 @Test
 public void toString_test() {
   assertEquals("morph(Type)", action.toString());
 }
Example #5
0
 @Test
 public void execute_test() {
   params.set(0, new Identifier("null"));
   action.execute(unit, act);
   verify(unit).morph(null);
 }
 public MorphingBehavior(Alpha a, Morph m) {
   alpha = a;
   morph = m;
   weights = morph.getWeights();
 }