Apparently I am making a 'war game' using cards, but there are bugs and problems


Randomise the card number of card 1


Same for the enemy. (just that it can only use 1,3,8 for card 1)


I made the same thing for card 1-5.

When card 1 is clicked:
It is supposed to do the attacking and defending for the first two procedures and deduct the player and enemy HP by subtraction at the end

Enemy stats
This is for the enemy.

I made 9 cards, which have different stats, and there are cards 1-5 for both players and enemies. (To make the game more balanced for the player, the enemy bot could only have a random card of 1,3,8 for card 1). However, the problem is that when 'Card 1' button is clicked by the player, the two procedures don't seem to work at all. Did I misuse any of the blocks, or were any blocks unnecessary?

Apparently I am new to App Inventor 2, and making this game as my assignment. Thank you for your help!

You will need to keep card decks for the player and for the enemy in separate lists, right?

You will also need a general procedure to shuffle a deck (a list.)

Study the intro to lists articles and the simplest shuffle procedure in

I don't see how that / (division) operator is helping you when computing enemy attack. I see that variable shrinking but never increasing.

Could you export and post your aia to help understand the game better?

By the way, you need to use lookup tables for the card values, instead of those if/the/elseif ladders.

Do you have card images for the cards?

Gameproject2.aia (1.6 MB)

I appreciate your help. I was jammed here for 7 hours yesterday.

I don't really understand what 'lookup tables'.

Oh, and the card images are included as well.

Thank you again!

I think I see where you got that '/' from in your code, but you have a problem.
On the card images, it is shorthand for offense vs defense, judging from your sample card image:

The '/' on each card has nothing to do with the '/' math division block. The card artists just needed room to separate the attack and defense numbers, and '/' looked nice and short.

Unfortunately, all nine of your cards have extra text that pretty much overrides the stats on the cards. These are your nine card types, in order, for the board:









If you want to play a simpler game based on just the attack and defense numbers, without the delayed effects mentioned in the card text, I suggest clipping off the text parts from the card images.

Alternatively, if you want to keep the promises made on the card images, you would need extra lists of future actions on future moves based on this move, i.e. 50% chance of Speed Dodge for the X-43.

I suggest reading up on dictionaries, and using the vehicle names as keys, to help lookup the various attributes of each card in separate dictionaries:

  • attack
  • defense

(If you want to just use lists and tables, use the Lookup in Pairs list block.)

Regarding your blocks, I see you are trying to randomize in your global init blocks.

That's not how you deal decks for the player and opponent.
You establish separate empty (initially) lists for the player and the opponent.
You start with a deck with all the cards.
You shuffle the deck. (See the lists FAQ)
Then you start removing item 1 of the deck and adding it to the player or the opponent alternately, until the list lengths of the players' hands are big enough (5?), or the deck is empty.