diff --git a/src/java/com/threerings/parlor/card/trick/data/TrickCardCodes.java b/src/java/com/threerings/parlor/card/trick/data/TrickCardCodes.java index 742779817..66535ecf9 100644 --- a/src/java/com/threerings/parlor/card/trick/data/TrickCardCodes.java +++ b/src/java/com/threerings/parlor/card/trick/data/TrickCardCodes.java @@ -28,14 +28,14 @@ import com.threerings.parlor.card.data.CardCodes; */ public interface TrickCardCodes extends CardCodes { - /** For four-player games, the top (opposite) player. */ - public static final int TOP = 0; - /** For four-player games, the bottom (own) player. */ - public static final int BOTTOM = 1; + public static final int BOTTOM = 0; /** For four-player games, the player on the left. */ - public static final int LEFT = 2; + public static final int LEFT = 1; + + /** For four-player games, the top (opposite) player. */ + public static final int TOP = 2; /** For four-player games, the player on the right. */ public static final int RIGHT = 3; diff --git a/src/java/com/threerings/parlor/card/trick/util/TrickCardGameUtil.java b/src/java/com/threerings/parlor/card/trick/util/TrickCardGameUtil.java index b2a28cb2b..02bfb859e 100644 --- a/src/java/com/threerings/parlor/card/trick/util/TrickCardGameUtil.java +++ b/src/java/com/threerings/parlor/card/trick/util/TrickCardGameUtil.java @@ -40,7 +40,7 @@ public class TrickCardGameUtil */ public static int getTeamIndex (int pidx) { - return pidx / 2; + return pidx & 1; } /** @@ -51,7 +51,7 @@ public class TrickCardGameUtil */ public static int getOtherTeamIndex (int tidx) { - return 1 - tidx; + return tidx ^ 1; } /** @@ -60,7 +60,7 @@ public class TrickCardGameUtil */ public static int getPartnerIndex (int pidx) { - return pidx ^ 1; + return pidx ^ 2; } /** @@ -72,7 +72,7 @@ public class TrickCardGameUtil */ public static int getTeamMemberIndex (int tidx, int midx) { - return tidx * 2 + midx; + return (midx << 1) | tidx; } /** @@ -82,15 +82,9 @@ public class TrickCardGameUtil public static int getNextInClockwiseSequence (int pidx) { // 0 - // 2 3 - // 1 - switch (pidx) { - case 0: return 3; - case 1: return 2; - case 2: return 0; - case 3: return 1; - default: return -1; - } + // 3 1 + // 2 + return (pidx + 1) & 3; } /** @@ -103,7 +97,7 @@ public class TrickCardGameUtil */ public static int getRelativeLocation (int pidx1, int pidx2) { - return RELATIVE_LOCATIONS[pidx1][pidx2]; + return (pidx2 - pidx1) & 3; } /** @@ -112,7 +106,7 @@ public class TrickCardGameUtil */ public static int getLeftIndex (int pidx) { - return getNextInClockwiseSequence(pidx); + return (pidx + 1) & 3; } /** @@ -121,7 +115,7 @@ public class TrickCardGameUtil */ public static int getRightIndex (int pidx) { - return getNextInClockwiseSequence(pidx) ^ 1; + return (pidx + 3) & 3; } /** @@ -130,7 +124,7 @@ public class TrickCardGameUtil */ public static int getOppositeIndex (int pidx) { - return pidx ^ 1; + return pidx ^ 2; } /** @@ -198,9 +192,4 @@ public class TrickCardGameUtil } return highest; } - - /** The locations of the other players for each player index. */ - protected static final int[][] RELATIVE_LOCATIONS = { - {BOTTOM, TOP, RIGHT, LEFT}, {TOP, BOTTOM, LEFT, RIGHT}, - {LEFT, RIGHT, BOTTOM, TOP}, {RIGHT, LEFT, TOP, BOTTOM} }; } diff --git a/src/java/com/threerings/parlor/game/data/TeamGameConfig.java b/src/java/com/threerings/parlor/game/data/TeamGameConfig.java index 72bd4c08f..7944d3648 100644 --- a/src/java/com/threerings/parlor/game/data/TeamGameConfig.java +++ b/src/java/com/threerings/parlor/game/data/TeamGameConfig.java @@ -24,15 +24,14 @@ package com.threerings.parlor.game.data; import com.threerings.parlor.data.TableConfig; /** - * Provides additional information for games with fixed teams. + * Provides additional information for games with teams. */ public interface TeamGameConfig extends TableConfig { /** - * Returns the number of players on the first n-1 of n teams. For - * instance, a game with four players in two partnerships would - * return { 2 }, indicating that players 0 and 1 are partnered - * against players 2 and 3. + * Returns the members of each team. For instance, a game with three + * players in two teams--players 0 and 2 versus player 1--would return + * { {0, 2}, {1} }. */ - public int[] getTeamCounts (); + public int[][] getTeamMemberIndices(); }