A
A
Alexey Lebedev2015-11-12 12:01:32
Programming
Alexey Lebedev, 2015-11-12 12:01:32

How to store this data structure?

We have 10 players each with their own number. Not necessarily in order.
1,7,25,13,44,18,77,84,33,10 Effects
can be applied to the player, for example:
Poison with 3-5 damage for 5 turns and Burning with 10-20 for 2 turns. There can be an unlimited number of effects at the same time.
P[1][1,3,7,5],[2,10,20,2].
P[7] [1,3,7,5]
P[25] [2,10,20,2]
Effects may vary. Let's say one ran out, he left, or new ones are added.
We go through all the effects every time we get to the right one.
Therefore, you need:
1) the ability to go through the list of effects.
2) adding to the end
3) deleting from anywhere.
Although this is debatable, it might be worth marking as "End" and skipping
var P = new Dictionary();
Or should the structure contain LIST<> consisting of arrays?
How to store all this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor, 2015-11-12
@swanrnd

1. player id with an array of links to effects attached to it (with effect duration)
2. list of all possible effects.

A
AtomKrieg, 2015-11-12
@AtomKrieg

In the player (actor) class, add an array or list of applied effects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question