|
I am making a simple game for Android in JavaScript. In order for a player to win the game, an array holding their score numbers has to match one of eight winning number combinations. My idea was to create a multidimensional array to hold the eight winning number combinations. Then I would have the game compare the players' score arrays with those combinations to see if anyone has won yet. This is what my multidimensional array looks like: Possible issue: My players' score arrays could have between 3 and 5 elements, so they may not have the same length as the winning combo array I'm trying to compare them to. Also, it shouldn't matter what order the score numbers are in. Whether the player's score array looks like "2,3,1", or "2,7,1,3", etc... I still want that player to win because their array contains "winCom1". Is there a good way to go about this method, if it's even possible? And if anyone has any alternate (i.e. simpler) ideas on how to check for winning number combos, I'd love to hear them. Thank you in advance!
(comments are locked)
|
An explanation:
Jul 15 '12 at 11:27 PM
whydoidoit
Thank you for your response! I tried that out, but the compiler gives 2 errors: 'Any' is not a member of 'Array' 'Intersect' is not a member of 'Object'. I will look deeper into Linq, as I've never heard of it. And I hadn't thought of using Intersect. So I will have to look into that, as well.
Jul 16 '12 at 01:30 AM
katie88
Ah sorry about that I have modified the answer (I forgot damn JS needs casts on in built arrays).
Jul 16 '12 at 01:41 AM
whydoidoit
Ahh that works perfectly! Thank you so much!!
Jul 16 '12 at 02:19 AM
katie88
Could you mark the questions as answered for me? Get's it off the unsolved list :)
Jul 16 '12 at 06:33 AM
whydoidoit
(comments are locked)
|
