From 054c4469f37536f8475e94d0bb10176ce3d7e4ea Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 22 Jan 2007 19:59:06 +0000 Subject: [PATCH] Changes to match alterations to abjectscript's StreamableArrayList. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@149 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/as/com/threerings/parlor/card/data/Deck.as | 18 ++++++++---------- src/as/com/threerings/parlor/card/data/Hand.as | 8 +++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/as/com/threerings/parlor/card/data/Deck.as b/src/as/com/threerings/parlor/card/data/Deck.as index 146ff2bb..093cf13a 100644 --- a/src/as/com/threerings/parlor/card/data/Deck.as +++ b/src/as/com/threerings/parlor/card/data/Deck.as @@ -21,9 +21,7 @@ package com.threerings.parlor.card.data { -import mx.collections.ArrayCollection; - -import com.threerings.util.Collections; +import com.threerings.util.ArrayUtil; import com.threerings.util.StreamableArrayList; /** @@ -58,7 +56,7 @@ public class Deck extends StreamableArrayList var hand :Hand = new Hand(); var offset :int = length - size; for (var ii :int = 0; ii < size; ii++) { - hand.addItem(removeItemAt(offset)); + hand.add(removeAt(offset)); } return hand; } @@ -72,7 +70,7 @@ public class Deck extends StreamableArrayList public function returnHand (hand :Hand) :void { addAll(hand); - hand.removeAll(); + hand.clear(); } /** @@ -84,17 +82,17 @@ public class Deck extends StreamableArrayList */ public function reset (includeJokers :Boolean) :void { - removeAll(); + clear(); for (var i :int = CardCodes.SPADES; i <= CardCodes.DIAMONDS; i++) { for (var j :int = 2; j <= CardCodes.ACE; j++) { - addItem(new Card(j, i)); + add(new Card(j, i)); } } if (includeJokers) { - addItem(new Card(CardCodes.RED_JOKER, 3)); - addItem(new Card(CardCodes.BLACK_JOKER, 3)); + add(new Card(CardCodes.RED_JOKER, 3)); + add(new Card(CardCodes.BLACK_JOKER, 3)); } } @@ -103,7 +101,7 @@ public class Deck extends StreamableArrayList */ public function shuffle () :void { - Collections.shuffle(this); + ArrayUtil.shuffle(_array); } } } diff --git a/src/as/com/threerings/parlor/card/data/Hand.as b/src/as/com/threerings/parlor/card/data/Hand.as index 106864ed..307c39a3 100644 --- a/src/as/com/threerings/parlor/card/data/Hand.as +++ b/src/as/com/threerings/parlor/card/data/Hand.as @@ -43,7 +43,7 @@ public class Hand extends StreamableArrayList { var members :int = 0; for (var i :int = 0; i < length; i++) { - if ((getItemAt(i) as Card).getSuit() == suit) { + if ((get(i) as Card).getSuit() == suit) { members++; } } @@ -63,9 +63,7 @@ public class Hand extends StreamableArrayList */ public function addAllCards (cards :Array) :void { - for (var i :int = 0; i < cards.length; i++) { - addItem(cards[i]); - } + addAll(cards); } /** @@ -74,7 +72,7 @@ public class Hand extends StreamableArrayList public function containsAllCards (cards :Array) :Boolean { for (var i :int = 0; i < cards.length; i++) { - if (indexOf(cards[i]) == -1) { + if (!contains(cards[i])) { return false; } }