@Test public void testGenerateStateChangeMesage() { Actor actor = mock(Actor.class); StateChangeStack stack = mock(StateChangeStack.class); MoveState m = new MoveState(new Angle(), Vector2D.ORIGIN, 0); when(stack.getStateChanges()).thenReturn(Arrays.asList(m)); when(actor.getEventStack(StateChangeStack.STACK_NAME)).thenReturn(stack); List<Message> messages = worldServerMessageFactory.generateChangeStateMessages(actor); Message newState = messages.get(0); assertEquals(newState.getArgument("id"), actor.getId()); assertEquals(newState.getArgument("relativeAngle"), m.angle.getRelativeAngle()); assertEquals(newState.getArgument("absoluteAngle"), m.angle.getAbsoluteAngle()); assertEquals(newState.getArgument("timeOfChange"), m.timeOfChange); assertEquals(newState.getArgument("xCoordinate"), m.position.getXCoordinate()); assertEquals(newState.getArgument("yCoordinate"), m.position.getYCoordinate()); }
public List<Message> generateChangeStateMessages(Actor changedActor) { List<Message> messages = new LinkedList<>(); EventStack eventStack = changedActor.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; for (MoveState m : stateChangeStack.getStateChanges()) { Message newState = MessageRegistry.getInstance().createMessage("StateChangeMessage"); newState.setArgument("id", changedActor.getId()); newState.setArgument("relativeAngle", m.angle.getRelativeAngle()); newState.setArgument("absoluteAngle", m.angle.getAbsoluteAngle()); newState.setArgument("timeOfChange", m.timeOfChange); newState.setArgument("xCoordinate", m.position.getXCoordinate()); newState.setArgument("yCoordinate", m.position.getYCoordinate()); messages.add(newState); } } return messages; }
WorldServerMessageFactory extends ServerMessageFactory { public List<Message> generateChangeStateMessages(Actor changedActor) { List<Message> messages = new LinkedList<>(); EventStack eventStack = changedActor.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; for (MoveState m : stateChangeStack.getStateChanges()) { Message newState = MessageRegistry.getInstance().createMessage("StateChangeMessage"); newState.setArgument("id", changedActor.getId()); newState.setArgument("relativeAngle", m.angle.getRelativeAngle()); newState.setArgument("absoluteAngle", m.angle.getAbsoluteAngle()); newState.setArgument("timeOfChange", m.timeOfChange); newState.setArgument("xCoordinate", m.position.getXCoordinate()); newState.setArgument("yCoordinate", m.position.getYCoordinate()); messages.add(newState); } } return messages; } }
WorldServerMessageFactory extends ServerMessageFactory { public List<Message> generateChangeStateMessages(Actor changedActor) { List<Message> messages = new LinkedList<>(); EventStack eventStack = changedActor.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; for (MoveState m : stateChangeStack.getStateChanges()) { Message newState = MessageRegistry.getInstance().createMessage("StateChangeMessage"); newState.setArgument("id", changedActor.getId()); newState.setArgument("relativeAngle", m.angle.getRelativeAngle()); newState.setArgument("absoluteAngle", m.angle.getAbsoluteAngle()); newState.setArgument("timeOfChange", m.timeOfChange); newState.setArgument("xCoordinate", m.position.getXCoordinate()); newState.setArgument("yCoordinate", m.position.getYCoordinate()); messages.add(newState); } } return messages; }  }
WorldServerMessageFactory extends ServerMessageFactory { public List<Message> generateChangeStateMessages(Actor changedActor) { List<Message> messages = new LinkedList<>(); EventStack eventStack = changedActor.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; for (MoveState m : stateChangeStack.getStateChanges()) { Message newState = MessageRegistry.getInstance().createMessage("StateChangeMessage"); newState.setArgument("id", changedActor.getId()); newState.setArgument("relativeAngle", m.angle.getRelativeAngle()); newState.setArgument("absoluteAngle", m.angle.getAbsoluteAngle()); newState.setArgument("timeOfChange", m.timeOfChange); newState.setArgument("xCoordinate", m.position.getXCoordinate()); newState.setArgument("yCoordinate", m.position.getYCoordinate()); messages.add(newState); } } return messages; }  Message generateNewlyVisibleMessage(WorldObject object); List<Message> generateChangeStateMessages(Actor changedActor); Message generateForcedStateMessage(MoveState forcedState); Message generateActorMoveSpeedMessage(double moveSpeed); Message generateNewlyInvisibleMessage(WorldObject object); Message generateWorldLoginResponse(); Message generateWorldFileResponse(byte[] worldFileBytes); Message generateWorldChecksumResponse(byte[] checkSum); }
WorldServerMessageFactory extends ServerMessageFactory { public List<Message> generateChangeStateMessages(Actor changedActor) { List<Message> messages = new LinkedList<>(); EventStack eventStack = changedActor.getEventStack(StateChangeStack.STACK_NAME); if (eventStack != null && eventStack instanceof StateChangeStack) { StateChangeStack stateChangeStack = (StateChangeStack) eventStack; for (MoveState m : stateChangeStack.getStateChanges()) { Message newState = MessageRegistry.getInstance().createMessage("StateChangeMessage"); newState.setArgument("id", changedActor.getId()); newState.setArgument("relativeAngle", m.angle.getRelativeAngle()); newState.setArgument("absoluteAngle", m.angle.getAbsoluteAngle()); newState.setArgument("timeOfChange", m.timeOfChange); newState.setArgument("xCoordinate", m.position.getXCoordinate()); newState.setArgument("yCoordinate", m.position.getYCoordinate()); messages.add(newState); } } return messages; }  Message generateNewlyVisibleMessage(WorldObject object); List<Message> generateChangeStateMessages(Actor changedActor); Message generateForcedStateMessage(MoveState forcedState); Message generateActorMoveSpeedMessage(double moveSpeed); Message generateNewlyInvisibleMessage(WorldObject object); Message generateWorldLoginResponse(); Message generateWorldFileResponse(byte[] worldFileBytes); Message generateWorldChecksumResponse(byte[] checkSum);  }