Examples of Rank


Examples of biz.smart.mdx.olap.function.Rank

//           RANK([Hierarchy].CurrentMember,
//               [OrderedSet])
//       {HEAD([OrderedSet], 10)} ON 1
   
    MdxValueExpression rankingMeasure =
      new Rank(
          orderedSetToRank.getMembersHierarchy().getCurrentMember(),
//          orderedSetToRank.getName())
          orderedSetToRank)
    .getReturn();
   
View Full Code Here

Examples of com.barrybecker4.game.card.Rank

    @Override
    public int compareTo(HandScore score) {
        if (this.type.ordinal() == score.type.ordinal()) {
            int numRanks = Math.min(this.ranks.size(), score.ranks.size());
            int i = 0;
            Rank thisRank;
            Rank thatRank;
            do
            {
                thisRank = this.ranks.get(i);
                thatRank = score.ranks.get(i);
                i++;
            } while (thisRank == thatRank && i < numRanks);

            return (i <= numRanks) ? thisRank.ordinal() - thatRank.ordinal() : 0;
        }
        return this.type.ordinal() - score.type.ordinal();
    }
View Full Code Here

Examples of com.poker.shared.Rank

    if (state.getProcess() != 0) {
      ArrayList<Card> dealerCards = state.getDealerCards();
      for (int i = 0; i < 3; i++) {
        Suit suit = dealerCards.get(i).getSuit();
        serialized += "_" + suit.name() + "_";
        Rank rank = dealerCards.get(i).getRank();
        serialized += rank.name();
      }
      ArrayList<Card> player1Cards = state.getPlayers().get(0)
          .getPlayerCards();
      for (int i = 0; i < 3; i++) {
        Suit suit = player1Cards.get(i).getSuit();
        serialized += "_" + suit.name() + "_";
        Rank rank = player1Cards.get(i).getRank();
        serialized += rank.name();
      }
      ArrayList<Card> player2Cards = state.getPlayers().get(1)
          .getPlayerCards();
      for (int i = 0; i < 3; i++) {
        Suit suit = player2Cards.get(i).getSuit();
        serialized += "_" + suit.name() + "_";
        Rank rank = player2Cards.get(i).getRank();
        serialized += rank.name();
      }
    }

    if (state.getProcess() == 2) {
      Choose choose = state.getPlayers().get(0).getChoose();
View Full Code Here

Examples of com.poker.shared.Rank

        ArrayList<Card> player1Cards = new ArrayList<Card>();
        ArrayList<Card> player2Cards = new ArrayList<Card>();
        for (int i = 4; i < 9;) {
          Suit suit = Enum.valueOf(Suit.class, tokens[i]);

          Rank rank = Enum.valueOf(Rank.class, tokens[i + 1]);
          Card card = new Card(suit, rank);
          dealerCards.add(card);
          i += 2;
        }
        state.setDealerCards(dealerCards);
        for (int i = 10; i < 15;) {
          Suit suit = Enum.valueOf(Suit.class, tokens[i]);
          Rank rank = Enum.valueOf(Rank.class, tokens[i + 1]);
          Card card = new Card(suit, rank);
          player1Cards.add(card);
          i += 2;
        }
        state.setPlayerCards(0, player1Cards);
        for (int i = 16; i < 21;) {
          Suit suit = Enum.valueOf(Suit.class, tokens[i]);
          Rank rank = Enum.valueOf(Rank.class, tokens[i + 1]);
          Card card = new Card(suit, rank);
          player2Cards.add(card);
          i += 2;
        }
        state.setPlayerCards(1, player2Cards);
View Full Code Here

Examples of com.poker.shared.Rank

    if (state.getProcess() != 0) {
      ArrayList<Card> dealerCards = state.getDealerCards();
      for (int i = 0; i < 3; i++) {
        Suit suit = dealerCards.get(i).getSuit();
        serialized += "_" + suit.name() + "_";
        Rank rank = dealerCards.get(i).getRank();
        serialized += rank.name();
      }
      ArrayList<Card> player1Cards = state.getPlayers().get(0)
          .getPlayerCards();
      for (int i = 0; i < 3; i++) {
        Suit suit = player1Cards.get(i).getSuit();
        serialized += "_" + suit.name() + "_";
        Rank rank = player1Cards.get(i).getRank();
        serialized += rank.name();
      }
      ArrayList<Card> player2Cards = state.getPlayers().get(1)
          .getPlayerCards();
      for (int i = 0; i < 3; i++) {
        Suit suit = player2Cards.get(i).getSuit();
        serialized += "_" + suit.name() + "_";
        Rank rank = player2Cards.get(i).getRank();
        serialized += rank.name();
      }
    }

    if (state.getProcess() == 2) {
      Choose choose = state.getPlayers().get(0).getChoose();
View Full Code Here

Examples of com.poker.shared.Rank

        ArrayList<Card> player1Cards = new ArrayList<Card>();
        ArrayList<Card> player2Cards = new ArrayList<Card>();
        for (int i = 4; i < 9;) {
          Suit suit = Enum.valueOf(Suit.class, tokens[i]);

          Rank rank = Enum.valueOf(Rank.class, tokens[i + 1]);
          Card card = new Card(suit, rank);
          dealerCards.add(card);
          i += 2;
        }
        state.setDealerCards(dealerCards);
        for (int i = 10; i < 15;) {
          Suit suit = Enum.valueOf(Suit.class, tokens[i]);
          Rank rank = Enum.valueOf(Rank.class, tokens[i + 1]);
          Card card = new Card(suit, rank);
          player1Cards.add(card);
          i += 2;
        }
        state.setPlayerCards(0, player1Cards);
        for (int i = 16; i < 21;) {
          Suit suit = Enum.valueOf(Suit.class, tokens[i]);
          Rank rank = Enum.valueOf(Rank.class, tokens[i + 1]);
          Card card = new Card(suit, rank);
          player2Cards.add(card);
          i += 2;
        }
        state.setPlayerCards(1, player2Cards);
View Full Code Here

Examples of freecell.model.Card.Rank

    @Override
    public boolean canMoveFrom(Pile other) {
        if (other.isEmpty()) {
            return false;
        }
        Rank otherRank = other.topCard().rank;
        Suit otherSuit = other.topCard().suit;
        if (isEmpty()) {
            return otherRank == Rank.ACE;
        }
        Rank thisRank = topCard().rank;
        Suit thisSuit = topCard().suit;
        return otherSuit == thisSuit
                && otherRank.value == thisRank.value + 1;
    }
View Full Code Here

Examples of net.bnubot.db.Rank

    return createAccount(accountName, createAccess, commanderAccount, subject);
  }

  public static void setAccountAccess(BNetUser commander, Account commanderAccount, Account subjectAccount, int targetAccess, boolean superUser, boolean whisperBack)
  throws InsufficientAccessException, CommandFailedWithDetailsException {
    Rank originalRank = subjectAccount.getRank();
    int originalAccess = originalRank.getAccess();
    if(targetAccess == originalAccess)
      throw new CommandFailedWithDetailsException("That would have no effect");

    Rank targetRank = Rank.get(targetAccess);
    if(targetRank == null)
      throw new CommandFailedWithDetailsException("Invalid rank: " + targetAccess);

    if(!superUser) {
      if(subjectAccount.equals(commanderAccount))
        throw new InsufficientAccessException("to modify your self", true);

      int commanderAccess = 0;
      if(commanderAccount != null)
        commanderAccess = commanderAccount.getAccess();
      // TODO: get addMax from the database
      int addMax = commanderAccess - 1;
      if(targetAccess > addMax)
        throw new InsufficientAccessException("to add users beyond " + addMax, true);
      if(originalAccess >= commanderAccess)
        throw new InsufficientAccessException("to add users ranked above " + (commanderAccess - 1), true);
    }

    subjectAccount.setRank(targetRank);
    subjectAccount.setLastRankChange(new Date(System.currentTimeMillis()));
    try {
      subjectAccount.updateRow();
      commander.sendChat(subjectAccount.getName() + "'s rank has changed from "
          + originalRank.getPrefix() + " (" + originalAccess + ") to "
          + targetRank.getPrefix() + " (" + targetAccess + ")", whisperBack);
    } catch(Exception e) {
      throw new CommandFailedWithDetailsException(e);
    }
  }
View Full Code Here

Examples of net.bnubot.db.Rank

      } catch(Exception e) {
        Out.exception(e);
      }

      Account rsAccount = Account.get(user);
      Rank rsRank = (rsAccount == null) ? Rank.get(0) : rsAccount.getRank();

      if(rsRank != null) {
        // Autopromotions
        Integer apDays = rsRank.getApDays();
        // Check that they meet the days requirement
        apBlock: if((apDays != null) && (apDays != 0)) {
          double timeElapsed = 0;
          if(rsAccount == null) {
            timeElapsed = rsUser.getCreated().getTime();
          } else if(rsAccount.getLastRankChange() != null) {
            timeElapsed = rsAccount.getLastRankChange().getTime();
          }

          timeElapsed = System.currentTimeMillis() - timeElapsed;
          timeElapsed /= 1000 * 60 * 60 * 24;
          if(timeElapsed < apDays)
            break apBlock;

          if((rsRank.getApWins() == null)
          || (rsRank.getApD2Level() == null)
          || (rsRank.getApW3Level() == null))
            break apBlock;
          int apWins = rsRank.getApWins().intValue();
          int apD2Level = rsRank.getApD2Level().intValue();
          int apW3Level = rsRank.getApW3Level().intValue();
          long wins[];
          if(rsAccount == null)
            wins = new long[] {0, 0, 0};
          else
            wins = rsAccount.getWinsLevels(GlobalSettings.recruitTagPrefix, GlobalSettings.recruitTagSuffix);

          boolean hasEnoughWins = false;
          hasEnoughWins |= ((apWins > 0) && (wins[0] >= apWins));
          hasEnoughWins |= ((apD2Level > 0) && (wins[1] >= apD2Level));
          hasEnoughWins |= ((apW3Level > 0) && (wins[2] >= apW3Level));
          hasEnoughWins |= ((apWins == 0) && (apD2Level == 0) && (apW3Level == 0));

          if(hasEnoughWins) {
            // Check RS
            long rs = 0;
            if(rsAccount != null)
              rs = rsAccount.getRecruitScore(GlobalSettings.recruitAccess);
            Integer apRS = rsRank.getApRecruitScore();
            if((apRS == null) || (apRS == 0) || (rs >= apRS)) {
              int rank = 0;
              if(rsAccount != null)
                rank = rsAccount.getAccess();
              else {
                String name = user.getFullAccountName();
                name = name.substring(0, name.indexOf('@'));
                try {
                  Account recoverAccount = Account.get(name);
                  if((recoverAccount != null)
                  && (recoverAccount.getAccess() <= 1)
                  && (recoverAccount.getBnLogins().size() == 0)) {
                    rsAccount = recoverAccount;
                    // Reset the account to rank zero, just in case
                    rsAccount.setRank(Rank.get(0));
                    rsUser.setAccount(rsAccount);
                    rsUser.updateRow();
                  } else {
                    rsAccount = createAccount(name, 0, null, rsUser);
                  }
                } catch(Exception e) {
                  Out.exception(e);
                  user.sendChat("I couldn't make an account for you: " + e.getMessage(), true);
                  break apBlock;
                }
              }

              // Store the old AP mail message
              String apMail = rsRank.getApMail();

              // Give them a promotion
              rsRank = Rank.get(++rank);
              rsAccount.setRank(rsRank);
              rsAccount.setLastRankChange(new Date(System.currentTimeMillis()));
              try {
                rsAccount.updateRow();
              } catch(Exception e) {
                Out.exception(e);
                break apBlock;
              }
              user.resetPrettyName()//Reset the presentable name
              source.sendChat("Congratulations " + user.toString(GlobalSettings.bnUserToStringCommandResponse) + ", you've recieved a promotion! Your rank is now " + rsRank.getPrefix() + " (" + rank + ").");
              if((apMail != null) && (apMail.length() > 0))
                Mail.send(null, rsAccount, apMail);
            } else {
              user.sendChat("You need " + Long.toString(apRS - rs) + " more recruitment points to recieve a promotion!", true);
            }
          } else {
            String msg = "You need ";
            switch(user.getStatString().getProduct()) {
            case STAR:
            case SEXP:
            case W2BN:
              msg += Long.toString(apWins - wins[0]) + " more win";
              if(apWins - wins[0] > 1)
                msg += "s";
              break;
            case D2DV:
            case D2XP:
              msg += "to reach Diablo 2 level " + apD2Level;
              break;
            case WAR3:
            case W3XP:
              msg += "to reach Warcraft 3 level " + apW3Level;
              break;
            default:
              break apBlock;
            }
            msg += " to recieve a promotion!";
            user.sendChat(msg, true);
          }
        }

        // Greetings
        String greeting = rsRank.getGreeting();
        if(greeting != null) {
          try {
            greeting = String.format(greeting, user.toString(), user.getPing(), user.getFullLogonName());
            source.sendChat(greeting);
          } catch(NoSuchMethodError e) {
View Full Code Here

Examples of net.bnubot.db.Rank

  public static void registerCommand(String name, CommandRunnable action) {
    if(commands.get(name) != null)
      throw new IllegalArgumentException("The command " + name + " is already registered");

    if(Command.get(name) == null) {
      Rank max = Rank.getMax();

      Command c = DatabaseContext.getContext().newObject(Command.class);
      c.setRank(max);
      c.setCmdgroup(null);
      c.setDescription(null);
      c.setName(name);
      try {
        c.updateRow();
      } catch (Exception e) {
        throw new IllegalStateException(e);
      }

      String message = "Created command " + name + " with access " + max.getAccess() + "; to change, use %trigger%setauth " + name + " <access>";
      for(Account a : max.getAccountArray())
        try {
          Mail.send(null, a, message);
        } catch (Exception e) {
          throw new IllegalStateException(e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.