Android Open Source - Do-not-get-annoyed C P U Game Player






From Project

Back to project page Do-not-get-annoyed.

License

The source code is released under:

Apache License

If you think the Android project Do-not-get-annoyed listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package mn100013d.pmu.models;
// w  w  w .  j a  v a 2 s  .  c  o m
import java.io.Serializable;
import java.util.ArrayList;

import mn100013d.pmu.controllers.GameController;
import mn100013d.pmu.services.Randomizer;
import android.os.CountDownTimer;

public class CPUGamePlayer extends GamePlayer implements Serializable {
  private Randomizer randomizer;

  public CPUGamePlayer(String name, int color, Board board, GameController gController,
      Randomizer randomizer) {
    super(name, color, board, gController);
    this.randomizer = randomizer;
  }

  @Override
  protected void _play() {
    randomizer.produce();
  }
//  private String getColorByNumber(int i){
//    switch (i){
//    case Color.BLUE: return "Blue player";
//    case Color.RED: return "Red player";
//    case Color.YELLOW: return "Yellow player";
//    case Color.GREEN: return "Green player";
//    }
//    return "GRESKA";
//  }
  @Override
  public void decide() {
    if (_dice != null) {
      final GamePlayer _player = this;   
      //_dice.startRoll();
      new CountDownTimer(1500, 500) {
        
        @Override
        public void onTick(long millisUntilFinished) {
          
        }
        
        @Override
        public void onFinish() {
          //_dice.stopRoll();
          ArrayList<Field> options = new ArrayList<Field>();
          options = board.getOptions(_player, _dice.getValue());
          if (options.size() == 0)
            gController.nextTurn();
          else{
            options.get(0).performClick();
          }
        }
      }.start();
      
    }

  }

}




Java Source Code List

mn100013d.pmu.BeginingActivity.java
mn100013d.pmu.GameTypeFragment.java
mn100013d.pmu.NewGameActivity.java
mn100013d.pmu.NewGameFragment.java
mn100013d.pmu.PauseFragment.java
mn100013d.pmu.PauseGameFragment.java
mn100013d.pmu.ScoresFragment.java
mn100013d.pmu.SettingsFragment.java
mn100013d.pmu.StartActivity.java
mn100013d.pmu.StartGameFragment.java
mn100013d.pmu.controllers.GameController.java
mn100013d.pmu.data.GameDataDbHelper.java
mn100013d.pmu.data.GameSettingsEditor.java
mn100013d.pmu.data.GameTableContract.java
mn100013d.pmu.exceptions.ContextNotSetException.java
mn100013d.pmu.exceptions.GameExceptions.java
mn100013d.pmu.exceptions.PlayerNotRegisteredException.java
mn100013d.pmu.models.Board.java
mn100013d.pmu.models.CPUGamePlayer.java
mn100013d.pmu.models.Color.java
mn100013d.pmu.models.Dice.java
mn100013d.pmu.models.Field.java
mn100013d.pmu.models.FinishField.java
mn100013d.pmu.models.GamePlayer.java
mn100013d.pmu.models.HomeField.java
mn100013d.pmu.models.HumanGamePlayer.java
mn100013d.pmu.models.PathField.java
mn100013d.pmu.models.Pawn.java
mn100013d.pmu.models.Result.java
mn100013d.pmu.services.FragmentProvider.java
mn100013d.pmu.services.GamePlayerFactory.java
mn100013d.pmu.services.PopupService.java
mn100013d.pmu.services.Randomizer.java
mn100013d.pmu.services.ShakeDetector.java
mn100013d.pmu.services.SoundService.java