Skip to content
Snippets Groups Projects
Commit c8ac7361 authored by edani95's avatar edani95
Browse files

Proto last bug fix

parent 4891e7c9
No related branches found
No related tags found
2 merge requests!40Proto last bug fix,!39Proto last bug fix
package game;
import java.util.ArrayList;
import java.util.Random;
import mapobjs.defobjs.Door;
import mapobjs.defobjs.Field;
import mapobjs.defobjs.Gate;
import mapobjs.defobjs.Portal;
import mapobjs.defobjs.ZPM;
import mapobjs.movobjs.Player;
import mapobjs.movobjs.Replicator;
......@@ -79,12 +81,38 @@ public class Model
sum += colonel.getZpmCount();
if(jaffa != null)
sum += jaffa.getZpmCount();
if(specDoor != null)
{
if(sum >= specOpen)
{
specDoor.setOpen(true);
}
}
if(sum % 2 == 0)
{
ArrayList<Field> options = new ArrayList<>();
for(int i = 0; i < map.size(); i++)
{
if(!map.get(i).hasElementOn())
{
options.add(map.get(i));
}
}
if(options.isEmpty())
return;
Random rnd = new Random();
int rndNum = rnd.nextInt(options.size());
Field tmp = options.get(rndNum);
tmp.addElement(new ZPM(tmp));
this.ZPMs++;
}
}
public boolean portalClose(Portal portal)
{
int i = 0;
......
......@@ -307,4 +307,9 @@ public class Field implements IElement {
{
toRemove.add(element);
}
public boolean hasElementOn()
{
return !elements.isEmpty();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment