- Home /
What is the right way to do this?
I'm sorry I can't describe the title any better because don't really know how to this. I will describe my problem here:
I am making a card game and I ask the 4 players if they want to do an action between 1 and 3. In the end, only one player gets to perform this action. The player who gets to perform an action is the player who wants to perform the highest action. If multiple players want to perform the same action, the player who decided first gets to perform the action. (When the game starts an int between 1 and 4 is chosen and that player gets to decide first. For example, if player 3 starts the order in which the players are asked is 3, 4, 1, 2) So if player 1 doesn't want to perform any action, player 2 action 2, player 3 action 3 and player 4 action 3, I want player 3 to be able to perform the action. All the players have their own script in which their desired action is stored.
I am very sorry for the so vague description and I hope someone understands what I need and can help me. Thanks in advance!
I don't think it is but I think my explaining is not very good :'D
Answer by Kishotta · Sep 23, 2017 at 02:28 PM
It seems you might be having trouble breaking this problem down into smaller parts. Assuming I understand your expected behavior, you're wanting:
Randomly sort a list of Players
Randomly sort a list of options
Display the randomized options to the players in sequence
Record each player's response
Parse the player responses
Execute the appropriate action
Number 4 seems to be the only really tricky one. It may be worth creating a Responses class to hold a reference to the player and the value they chose (It sounds like you have something similar to this already). Those responses can be stored in an array/list/ect. for easy use in #5.
To more appropriately answer your question, I think it's important to note that, as with most coding problems, there is no right way to do this. But the preceding steps should be a decent starting point.
Sorry if this isn't particularly helpful at all!
Sorry I think I haven't explained my problem very well, this isn't exactly what I was looking for but you've given me an idea! Thanks for for taking your time!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Making a bubble level (not a game but work tool) 1 Answer
An OS design issue: File types associated with their appropriate programs 1 Answer
Import graph and read data 1 Answer