This site requires JavaScript, please enable it in your browser!
Greenfoot back
dkalfpqpfjq
dkalfpqpfjq wrote ...

2019/4/17

Selecting a card that is on the slot

1
2
3
danpost danpost

2019/4/21

#
dkalfpqpfjq wrote...
Would you like to see what I've got so far? I only got place card in empty slot and hover-highlight done so far. I think it would be easier for you to look through.
Upload it (with source) and I will take a gander at it.
dkalfpqpfjq dkalfpqpfjq

2019/4/21

#
danpost wrote...
Upload it (with source) and I will take a gander at it.
my scenario
danpost danpost

2019/4/21

#
dkalfpqpfjq wrote...
<< Link Omited >>
The Card class should be a separate Actor subclass. A Card object is not a Player object. Let me try to explain what I think your misunderstanding is here. You have two players in your game -- one human and one robot. The Player class is a "wrapper" for both players -- not specific to either one. It is to contain only those things that BOTH the human and the robot have in common. Both will have (initially) a set (list) of 12 cards and an empty set (list) for cards that will be moved to slots. Both have a current state of having the turn or not having the turn. Both, on their respective turns, will perform some action(s). Since the actions of the human are controlled by the keyboard and the actions of the robot are controlled by some programming algorithm, the specific codes for these action should be in their respective subclasses of Player (Bot or Human).
dkalfpqpfjq dkalfpqpfjq

2019/4/21

#
danpost wrote...
The Card class should be a separate Actor subclass...
Ah, okay. 1) So in Player class, I can have a list of cards not on slot and a list of cards on slot. So then will the parameter of Bot be nothing inside, and MyWorld will create Bot's card by
for (int i = 0; i<12; i++)
        {
            addObject(new Card(card[i]+".png", HP[i], attack[i]),60+i*120, 0); 
        }
instead of Bot? Card visually represents both Human and Bot's cards, am I correct? 2) In the list of cardsOnSlot, I can store both Human and Bot's cards if it is on the slots?! 3) How would MyWorld control both selected-highlights? Should I reference to MyWorld method in Human class when a card on slot is single-clicked? 4) How would I get the attack, health value of two selected-cards? Maybe using the location of selected-highlights? Thank you for your correction!
danpost danpost

2019/4/21

#
dkalfpqpfjq wrote...
So in Player class, I can have a list of cards not on slot and a list of cards on slot. So then will the parameter of Bot be nothing inside, and MyWorld will create Bot's card by
for (int i = 0; i<12; i++)
        {
            addObject(new Card(card[i]+".png", HP[i], attack[i]),60+i*120, 0); 
        }
instead of Bot? Card visually represents both Human and Bot's cards, am I correct?
Correct. However the list for cards not on slot will need to populated with those cards.
In the list of cardsOnSlot, I can store both Human and Bot's cards if it is on the slots?!
Since both Bot and Human extend the Player class, each list declared in the Player class will be assigned as independent fields to any object created from those classes. It is equivalent to having two classes that extend Actor of (1) Player+Bot; and (2) Player+Human.
How would MyWorld control both selected-highlights? Should I reference to MyWorld method in Human class when a card on slot is single-clicked?
In my demo, I used a field in my MyWorld class to hold the player's selected slot card.
How would I get the attack, health value of two selected-cards? Maybe using the location of selected-highlights?
The field in the MyWorld class holds the player's selected card, whose health and attack values can be gotten directly. When a click is detected on an opponent's slot card (while the field for player's selected card is not null), you will have a reference to it at that time; so, its health and attack will also be readily available.
dkalfpqpfjq dkalfpqpfjq

2019/4/21

#
Okay. Thank you for your reply!
You need to login to post a reply.
1
2
3