Exemple #1
0
 /**
  * Accessor method for accessing list of Plays.
  *
  * @return clonedList
  */
 public List<Play> getTrick() {
   List<Play> clonedList = new ArrayList<Play>(fPlays.size());
   for (Play play : fPlays) {
     clonedList.add(new Play(play.getPlayer(), play.getCard()));
   }
   return clonedList;
 }
Exemple #2
0
  /**
   * @return The player who wins the trick to date.
   * @throws ModelException is the trick is empty.
   */
  public String getWinner() throws ModelException {
    String winner;
    Card maxCard;
    Card compareCard;

    if (fPlays.size() == 0) // Check if trick is empty, and return exception.
    {
      throw new ModelException("The trick is empty.");
    }

    Suit led = getSuitLed();
    maxCard = (fPlays.get(0)).getCard();
    winner = new String(fPlays.get(0).getPlayer());

    for (Play play : fPlays) {
      compareCard = play.getCard();
      if (compareCard.getSuit().equals(led)) {
        if (compareCard.compareTo(maxCard) > 0) {
          maxCard = compareCard;
          winner = new String(play.getPlayer());
        }
      }
    }
    return winner;
  }
Exemple #3
0
 private void play(final Object message) {
   final ActorRef self = self();
   final Play request = (Play) message;
   final List<URI> uris = request.uris();
   final int iterations = request.iterations();
   final org.mobicents.servlet.restcomm.mgcp.Play play =
       new org.mobicents.servlet.restcomm.mgcp.Play(uris, iterations);
   stop();
   ivr.tell(play, self);
   ivrInUse = true;
 }
  @Override
  public void render(GameContainer container, StateBasedGame state, Graphics g)
      throws SlickException {

    /*g.setColor(Color.gray);
    g.fillRect(0, 0, container.getWidth(), container.getHeight());
    g.setColor(Color.black);*/

    play.renderWorld(g);
    g.setColor(Color.white);

    image.draw(0, 0, container.getWidth(), container.getHeight());

    float offset = 0;
    for (PlayerUI player : play.players) {
      g.drawString(
          player.agent.getName()
              + " died of exposure after only "
              + Math.floor(player.agent.getExpiredTime())
              + " hours.",
          10,
          scroller + offset);
      offset -= 30;
    }

    g.drawString(
        "press Escape to exit or Enter to start again",
        container.getWidth() / 2 - 250,
        container.getHeight() / 2 + 300);
  }
Exemple #5
0
  public static void main(String[] args) {
    Phrase phr = new Phrase();

    // create a random walk
    int pitch = 60;
    for (int i = 0; i < 12; i++) {
      Note n = new Note(pitch += (int) (Math.random() * 8 - 4), SQ * (int) (Math.random() * 2 + 1));
      phr.addNote(n);
    }

    // repeat the whole thing three times
    Mod.repeat(phr, 3);

    // see the result at this stage
    View.show(phr);

    // repeat beats 2 - 4 three times
    Mod.repeat(phr, 3, 2.0, 4.0);

    // see the result of this change
    View.show(phr, 50, 50);

    // hear the result
    Part p = new Part();
    Score s = new Score();
    p.addPhrase(phr);
    s.addPart(p);
    s.setTempo(140.0);

    Play.midi(s, false);
    // false so that it doesn't close everything, the view.show() window
    // in particular

    Write.midi(s, "Repeat.mid");
  }
 @Override
 public void affectCharStats(MOB E, CharStats stats) {
   super.affectCharStats(E, stats);
   if ((E != null) && (E != invoker()) && (stats.getCurrentClass().baseClass().equals("Bard"))) {
     int lvl = adjustedLevel(invoker(), 0) / 10;
     if (lvl < 1) lvl = 1;
     stats.setClassLevel(stats.getCurrentClass(), stats.getCurrentClassLevel() + lvl);
   }
 }
Exemple #7
0
  public void songManager() {
    UI ui = new UI();
    int choice = ui.getChoice();
    Play p = new Play(this);

    while (choice != 5) {
      switch (choice) {
        case 1:
          sortByArtist();
          print();
          break;
        case 2:
          sortByTitle();
          print();
          break;
        case 3:
          Scanner sc = new Scanner(new InputStreamReader(System.in));
          int songChoice = 0;
          while (songChoice < 1 || songChoice > size()) {
            System.out.println("Enter Song Choice: ");
            sortByArtist();
            print();
            songChoice = sc.nextInt();
          }
          try {
            p.playSong(songChoice, this);
          } catch (JavaLayerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          break;
        case 4:
          if (player != null) {
            player.close();
          }
          break;
        default:
          break;
      }
      choice = ui.getChoice();
      if (choice == 5) break;
    }
  }
Exemple #8
0
 public void affectCharStats(MOB mob, CharStats stats) {
   super.affectCharStats(mob, stats);
   if (mob == invoker) return;
   if (invoker() != null)
     stats.setStat(
         CharStats.STAT_SAVE_MAGIC,
         stats.getStat(CharStats.STAT_SAVE_MAGIC)
             - (invoker().charStats().getStat(CharStats.STAT_CHARISMA)
                 + (adjustedLevel(invoker(), 0) * 2)));
 }
 @Override
 public void affectCharStats(MOB mob, CharStats stats) {
   super.affectCharStats(mob, stats);
   if (invoker() != null)
     stats.setStat(
         CharStats.STAT_SAVE_MIND,
         stats.getStat(CharStats.STAT_SAVE_MIND)
             + (adjustedLevel(invoker(), 0) * 2)
             + invoker().charStats().getStat(CharStats.STAT_CHARISMA));
 }
 @Override
 public void affectPhyStats(Physical E, PhyStats stats) {
   super.affectPhyStats(E, stats);
   if ((E instanceof MOB)
       && (E != invoker())
       && (((MOB) E).charStats().getCurrentClass().baseClass().equals("Bard"))) {
     int lvl = adjustedLevel(invoker(), 0) / 10;
     if (lvl < 1) lvl = 1;
     stats.setLevel(stats.level() + lvl);
   }
 }
Exemple #11
0
  /**
   * The game view.
   *
   * @param Context context
   * @param Activity activity
   * @param int stage - The stage to load.
   * @param int level - The level to load.
   * @param float screenDensity - The screen density.
   */
  public GameView(Context context, Play activity, int stage, int level, float screenDensity) {
    super(context);

    mGameContext = context;
    mGameActivity = activity;

    mScreenDensity = screenDensity;

    mPlayerStage = stage;
    mPlayerLevel = level;

    mGameTileData = new GameTileData(context);
    mGameLevelTileData = new GameLevelTileData(context);

    mGameTileTemplates = mGameTileData.getTilesData();

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);

    // create thread only; it's started in surfaceCreated()
    thread = new GameThread(holder, context, null);

    setFocusable(true);

    mUiTextPaint = new Paint();
    mUiTextPaint.setStyle(Paint.Style.FILL);
    mUiTextPaint.setColor(Color.YELLOW);
    mUiTextPaint.setAntiAlias(true);

    Typeface uiTypeface = Typeface.createFromAsset(activity.getAssets(), "fonts/Molot.otf");
    if (uiTypeface != null) {
      mUiTextPaint.setTypeface(uiTypeface);
    }
    mUiTextPaint.setTextSize(
        mGameContext
            .getApplicationContext()
            .getResources()
            .getDimensionPixelSize(R.dimen.ui_text_size));

    startLevel();
    thread.doStart();
  }
Exemple #12
0
 public void setProficiency(int newProficiency) {
   super.setProficiency(100);
 }
Exemple #13
0
 public void play() {
   bird_part.setTempo(120); // Default: 60
   Play.midi(bird_part);
 }