#+TITLE: Seq

* Kampfrunde
#+BEGIN_SRC plantuml :file kampf.png
actor Spieler as user
participant LibGDX as client
participant ShipController as ship
participant CrewmemberController as crew
participant WeaponController as weapon

box "GameEngine"
  participant client
end box

box "GameServer"
  participant ship
  participant crew
  participant weapon
end box

loop
   loop
   user -> client: Set Power of Ship s
   client -> client: getPowerRequired(): int
   client -> client: setPowerCurrent(int s): void
   client -> ship: updateSection(s.setpowerCurrent(int Value))): JSON
   ship -> client: energiekResponse(Ship s): JSON
   client -> user: Update Energie

   end loop

   loop
        user -> client: select Crew & Section by id
        client -> crew: setCremMemberDestination(Ship s, Crewmember c, Section sec)
        crew -> ship: findPath(Section s.getSections, Section start, Section End): List<Section>
        ship -> crew: updateCrewMember(Ship s, List<Section>, CrewMember c): JSON
        crew -> ship: applyCrewSkills(Ship s): void
        ship -> client: crewMemberController.response(Ship s): JSON
        client -> user: Animate Change of Crew Position
   end loop

   loop

   user -> client: Attack Target Section with  Weapon
   client -> ship: startAttack(Weapon w, Section sec, Ship s): JSON
       loop
            ship -> weapon: getShield(Ship s): Shield
            weapon -> weapon: canAttack(Weapon W, Shield): Boolean
            weapon -> weapon: calculateDammage(Weapon w , Section s): Ship
            weapon -> client: applyAttack(Weapon w, Weapon): Weapon // HP, Shield
            client -> ship: validateShip(Ship sNew): Boolean
       end loop
       ship -> client: updateShip(Ship s): JSON
   client -> user: Inform user of Upadate Succes
   end loop
end loop

user -> user: Confirm End of Round


#+END_SRC

#+RESULTS:
[[file:kampf.png]]



 keine endschloss Schleife
benutzt eine bestehnde verbindung als Socket mit keep alive
Dann status ändern. Auf dem Socket ein Object Stream Verwenden

#+BEGIN_SRC plantuml :file example.png
actor Utilisateur as user
participant "formSign.js" as form <<Contrôleur formulaire>>
participant "Sign.java" as controler <<(C,#ADD1B2) Contrôleur formulaire>>
participant "Secure.java" as secure <<(C,#ADD1B2) authentification>>
participant "Security.java" as security <<(C,#ADD1B2) sécurité>>

box "Application Web" #LightBlue
	participant form
end box

box "Serveur Play" #LightGreen
	participant controler
	participant secure
	participant security
end box

user -> form : submitSignIn()
form -> form : getParameters()
form -> form : result = checkFields()

alt result

    form -> controler : formSignIn(email,pwd)
    controler -> controler : result = checkFields()

    alt result
    	controler -> secure : Secure.authenticate(email, pwd, true);
    	secure -> security : onAuthenticated()
    	security --> form : renderJSON(0);
    	form --> user : display main page
    else !result
    	controler --> form : renderJSON(1)
    	form --> user : display error
    end

else !result
	form --> user : display error
end

#+END_SRC

#+RESULTS:
[[file:example.png]]

* Client  / Server Kommunikaton
#+BEGIN_SRC plantuml :file sync.png
participant AgentInfoCache as cache
participant AgentInfoQuery as query
participant PollingRequestCallback as callback
participant AgentResponse as response
participant LibGDXAsyncRetriever as async

activate cache


    cache -> cache: Create Query for each host
    activate query
    cache -> query: run query
    query -> query: generate HTTPPingRequest
    query -> query: generate AgentResponse
    activate callback
    query -> callback: create a PollingRequestCallback
    deactivate callback
    callback -> query
    query -> response: agentResponse.getStatus(callBack)
    activate response
    response -> async: make HTTP Request
    activate async
    async -> async: submit the request
    deactivate response
    deactivate async
    async -> response: return future
    response -> query: return method
    deactivate query
    query -> callback: updateServer

#+END_SRC

#+RESULTS:
[[file:sync.png]]
