package simsos.scenario.mci;

import simsos.simulation.component.Action;
import simsos.simulation.component.Agent;
import simsos.simulation.component.World;

import java.util.HashMap;
import java.util.Random;

/**
 * Created by mgjin on 2017-06-28.
 */
public class Patient extends Agent {
    private enum Status {Initial, Waiting, OnPTS, Healing}
    private enum Severity {Delayed, Immediate}

    private String name;
    private Status status;
    private Severity severity;
    private Location location;

    public Patient(World world, String name) {
        super(world);

        this.name = name;
        this.reset();
    }

    public Location getLocation() {
        return this.location;
    }

    @Override
    public Action step() {
        return new Action(1){
            @Override
            public void execute() {

            }

            @Override
            public String getName() {
                return null;
            }
        };
    }

    @Override
    public void reset() {
        Random rd = new Random();

        this.status = Status.Initial;
        if (rd.nextInt(10) < 7)
            this.severity = Severity.Delayed;
        else
            this.severity = Severity.Immediate;
        this.location = new Location(rd.nextInt(9), rd.nextInt(9));
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public HashMap<String, Object> getProperties() {
        return new HashMap<String, Object>();
    }
}

@@ -23,16 +23,54 @@
 o.mci;%0A%0A
+import simsos.sa.StatisticalAnalyzer;%0A
 import s
@@ -511,16 +511,43 @@
 verity;%0A
+    private int lifePoint;%0A
     priv
@@ -570,16 +570,43 @@
 ation;%0A%0A
+    private Action bleed;%0A%0A
     publ
@@ -718,24 +718,40 @@
 t();%0A    %7D%0A%0A
+    @Deprecated%0A
     public L
@@ -848,24 +848,71 @@
 on step() %7B%0A
+        if (this.status == Status.Initial)%0A    
         retu
@@ -927,18 +927,23 @@
 ction(1)
+ 
 %7B%0A
+%0A   
         
@@ -938,32 +938,33 @@
 %0A               
+ 
 @Override%0A      
@@ -949,32 +949,36 @@
       @Override%0A
+    
             publ
@@ -993,25 +993,71 @@
 execute() %7B%0A
-%0A
+                    status = Status.Waiting;%0A  
             
@@ -1052,27 +1052,33 @@
             
+  
 %7D%0A%0A
+    
             
@@ -1079,32 +1079,36 @@
       @Override%0A
+    
             publ
@@ -1149,44 +1149,215 @@
     
+    
 return 
-null;%0A            %7D%0A        %7D
+%22Call for Rescue%22;%0A                %7D%0A            %7D;%0A        else if (this.status == Status.Healing)%0A            return Action.getNullAction(1, %22Stable%22);%0A        else%0A            return this.bleed
 ;%0A  
@@ -1631,60 +1631,421 @@
 is.l
-ocation = new Location(rd.nextInt(9), rd.nextInt(9))
+ifePoint = 150 + (rd.nextInt(30) - 15); // 150 +- 15%0A        this.location = new Location(rd.nextInt(9), rd.nextInt(9));%0A%0A        this.bleed = new Action(1) %7B%0A%0A            @Override%0A            public void execute() %7B%0A                if (lifePoint %3E 0)%0A                    lifePoint--;%0A            %7D%0A%0A            @Override%0A            public String getName() %7B%0A                return null;%0A            %7D%0A        %7D
 ;%0A  

Implement Patient actions