Okay im a desperate need of some help here im currently doing a uni java project... im creating a single player battle war game that is turn based. ill give the overview i have wrote underneath but i need some help sorting out was classes i need and putting them into a UML class digram. IF anyone can help me it would be fantastic... right here we go...

I am going to create an Amy based medieval battle system that will be used in a game where 2 players play out a hypothetical battle sequence. The 1st method will implement the size of the army. Choosing number of units from mounted knight, infantry and archers. Also set there will be a constant of 200 turns in a battle. These turns will be decremented when each turn is finished.

The army will hold the amount of units in each subclass with a unique ID for each unit. These units will be called into battle using the Main method (). There will be no enemy in this particular demo of the system.

The Army will be able to charge all at once as one complete fighting unit and also use their particular attributes against the enemy. There will be 3 types of unit: archer, infantry and mounted Knights. The Archers will be split into two different types of units called Longbow and Crossbow as both of these units show different attributes.

Each Unit will be defined a number of hit points; these hit points will be decremented when the second player battles the 1st player. These Hit points will be defined in the army class as archers = 50, Infantry = 70 and mounted knights as 100 when the hit points = 0 then that unit is destroyed and takes no further part in the game.

Also there is movement method of each unit. These will be set as archers can move at 20 yards per turn, mounted knights can move at 50 yards per turn and the infantry can travel at 10 yards per turn. When the entire army is moving then they travel at 5 yards per turn, both armies will start out of range from each other at 250 yards

The archer class will hold the formation and fire method, as the reload time greatly differs from longbow to crossbow then the loading will be held in there subsequent classes.

The longbow reload time will be set to 1 where as the crossbow reload time will be set to 5. Given separate length of the shot and power of the shot then these will also be set up in the subsequent classes. Longbow length will be set at 200=> yards and power of 4 at a length of 100=> yards the power is 5 and at length 50=> yards the longbow power will reduce to 2 where as the crossbow will be set at 50=> yards and power at 4. When at 20=> yards the longbow is ineffective and the crossbow power will increase to 6. When at close range both archers will be ineffective

The effectiveness of both mounted knights and infantry is only at close range at a hit point ratio of 10

The cost of each army will keep the game fair, the cost for each unit will be Longbow = 100, crossbow = 50, infantry = 80 and mounted knights will cost 200 with a max of 1000 points.

Also there is a unit aiming system as 1 unit can only target on unit at a time. This will not be implemented, as there will be no targets available.

Recommended Answers

All 5 Replies

I can already see you using the Bridge and/or Strategy pattern from the specs.

You'll also most likely end up using the Observer pattern.

Try not to be distracted by the specs too much. Break down the problem.

You're limited to 1000 points of units. What I'd do is have the army class abstractly contain a set of units to use (an array or list of units - your call).

The set of type of units will be set during construction of the army, but you may also want to provide functionality to set the type of units during run-time to show flexibility to the system (though this is most likely not required).

Each abstract unit has a cost() method that defines how much that unit will cost.

You van use a separate list that will be the result of populated units (obviously an implementation of a random generator and a data type that contains the max amount of cost for the army).

Each Army class (or class the encapsulates the units) can act as the Observable and signal to all units, or observers, within the given army to initiate an attack.

Implement an attack(Unit other) command for all units, and also a react(Unit fromUnit) command. Since the kind of attacks can vary, you may (or may not) want to consider using an encapsulated Action interface that has a method act() which defines what will be done during an attack or when one receives damage (though this may be overkill for this assignment).

The moment a unit has lost too much health due to attacks, you should unregister them from being an Observer to receive commands from the army class (because honestly they shouldn't receive commands when they're dead - they can't).

As for the range implementations, you may want to have some kind of number representation of the range returned by a method. Every unit has some kind of theoretical range. Consider mapping your units out on a grid - units can't attack anything beyond their range so obviously the range will be used as a condition for a unit relative to the closest target to it. In order for this to work, each unit in each army will have to somehow know where all other enemy units are before an attack. This can be done by the Observable army signaling the position of all targets (or just signaling which targets exist and supply an implementation of the unit coordinates to each individual unit to keep track of themselves).

Hopefully this was helpful.


commented: Very helpful answer. +11

great stuff... you have sorted out alot in my head there, its slowly taking shape. you guys have been a massive help.


ill let you know how it turns out

alright have a look at my attachment of the image i have done for my UML and tell me if you think its right or not. and if not suggest any improvements pllllleeeeaaaase


this Archers means has aggreagatin relationship or no?

Which UML Diagramming software are you using? I can see beautiful Diagrams ;)
Sorry for hijacking the thread for a minute :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.