#+TITLE: Multiplayer

#+BEGIN_SRC dot :file multi1.png
 digraph finite_state_machine {

 loginScreen -> selectScreen;
 selectScreen -> shipSelectScreen

 shipSelectScreen -> stationMap
 stationMap -> shopScreen
 shopScreen -> stationMap

 stationMap -> travelScreen
travelScreen -> stopScreen
stopScreen -> stationMap

stopScreen ->  stationMap
stopScreen-> combatScreen
combatScreen -> stationMap

 }
#+END_SRC

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


#+BEGIN_SRC dot :file multiFight.png
 digraph finite_state_machine {

canShot -> shot
canShot -> canShot
 }
 #+END_SRC

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




#+BEGIN_SRC dot :file Multiplayer.png
 digraph finite_state_machine {


lobbyEnter -> lobbyWaiting  [label="enter the Lobby"]
lobbyWaiting -> lobbyWaiting
lobbyWaiting -> lobbyFull [label="other player joins"]

lobbyWaiting -> singlePlayer [label="no player found"]



 lobbyFull -> readyAllPressed ->  startGame
 }
 #+END_SRC

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



#+BEGIN_SRC dot :file jumping.png
digraph jumping {

        selectShipScreen -> stationMap [label="begin game"]
        stationMap -> { stopScreen, shopScreen }
        shopScreen -> stationMap

        stopScreen -> fightScreen

        fightScreen -> looseScreen
        looseScreen -> stationMap        [label="looses half of Ressources"]

        stopScreen -> stationMap


       fightScreen -> winScreen -> stationMap



       stationMap -> jumpWaiting -> jumpWaiting -> jumpingAllReady -> travelScreen
       travelScreen -> stationMap [label="Get all Acotrs from Stop"]
}

#+END_SRC

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



#+BEGIN_SRC dot :file kampf.png

digraph automaton {
rankdir=LR

    subgraph cluster_0 {
        label="Client";



        combatScreen -> {chooseWeapon, selectTarget moveCrewMember};
        chooseWeapon -> combatScreen [label="choose weapon with W"];
        selectTarget -> findWeaponByNameAndShip [label="chooses the target"];
        findWeaponByNameAndShip -> combatScreen;
        combatScreen -> fireWeapon [label="SPACE"];
        fireWeapon -> logicOfFirePlayer [label="Target with selected Weapons"];
        logicOfFirePlayer -> shotValidation [label="List<Weapon> weapons"];


        handleShot -> {drawBullet, removeShield, drawExplosion}




        }

    subgraph cluster_1 {
        label="Shot Validation";

        shotValidation -> canShot [label="can the Weapons shot?"]

        canShot -> checkHP [label="is hp over 0"]
        checkHP -> noShot
        checkHP -> outSideRange [label="(currentTime - lastShot) > coolDow"]
        outSideRange -> noShot [label="false"]
        noShot -> shotValidation
        outSideRange -> isUsable  [label="true"]
        isUsable -> fireShot [label="true"]
        fireShot -> shotValidation  [label="List<Boolean> bullets"]

        }



    subgraph cluster_2 {
        label="Fire Weapon"

        shotValidation -> makeAShot [label="List<Weaons> weaponsToFire"]

        makeAShot -> hasHit [label="% hitRate + % random"]

        hasHit -> miss [label="hasHit < 1"]
        miss -> shotAnswer


        hasHit -> hitShield[label="Shield < 0"]
        hitShield -> reduceShield [label="shield - dammage"]
        reduceShield -> shotAnswer

        hasHit -> removeHealth [label="hp - dammage"]
        removeHealth -> setUsableFalse
        setUsableFalse -> removeOxygen [label="oxygen - removeOxygen"]
        removeOxygen -> shotAnswer



        shotAnswer -> handleShot

    }


    subgraph cluster_3 {
             label="Turn Manger"


        combatScreen -> WAITING [label="END TURN"]
        fightStart -> FightState;
         FightState -> {WAITING, PLAYING} [label="GET"]
        WAITING -> FightState [label="Wait for Turn"]
        PLAYING -> combatScreen [label="SET PLAYING"]

    }

}
#+END_SRC

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





#+BEGIN_SRC dot :file fightMechanik.png


digraph automaton {

    start -> checkHP [label="hp > 0"]
    checkHP ->  loosesFight [label="false"]

    #start -> getCrewMember[label="site == 0"]
    #getCrewMember -> loosesFight [label="true"]


}



#+END_SRC

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



#+BEGIN_SRC dot :file kampfRunde.png
digraph automaton {
#rankdir=LR
startFight -> waitForTurn [label="Button Start Fight"]
           waitForTurn -> makeTurn [label="Text: waiting ..."]
           makeTurn ->{energieVerteilen, attackWithWeapon, moveCrew} -> makeTurn
           makeTurn -> endTurn [label="Button: End Turn"]
           endTurn -> waitForTurn [label="Server nextPlayer"]
           }

#+END_SRC






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



#+BEGIN_SRC dot :file actorFight.png

digraph automaton {

        playerEndsTurn -> actorFight [label="GET /game/fight/{session}"]
        actorFight -> loadValues [label="require section, weapon, ship"]
        loadValues-> loadValues  -> selectedTarget -> setObjectiv -> setObjectiv -> loadAttackWeapons -> loadAttackWeapons
        loadAttackWeapons -> shotValidation [label="select all legal Weapons"]
        shotValidation -> weaponsWhichCanFire [label="validate"]
        weaponsWhichCanFire -> fireWeapon [label="fire Shot"]
        fireWeapon -> shotValidation [label="check if can fire again"]
        fireWeapon -> returnShip [label="when no wepaon can fire"]


        }

#+END_SRC

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



#+BEGIN_SRC scala
trait FullTummy
trait Bird
trait Catch
trait Cat
def catch(hunter: Cat, prey: Bird): Cat with Catch
def eat(consumer: Cat with Catch): Cat with FullTummy
val story = (catch _) andThen (eat _)
story(new Cat, new Bird)
#+END_SRC



#+BEGIN_SRC scala
case class Player(name: String, score: Int)
def declareWinner(p: Player): Unit =
  println(p.name + “ is the winner!”)
def winner(p1: Player, p2: Player): Unit =
  if (p1.score > p2.score) declareWinner(p1) else declareWinner(p2)
#+END_SRC

Seite 27, 40



#+BEGIN_SRC plantuml :file kommunikation.png

skinparam state {
    FontColor          white
    AttributeFontColor white
    FontSize           17
    AttributeFontSize  15
    AttributeFontname  Droid Sans Mono
    BackgroundColor    #527BC6
    BorderColor        black
    ArrowColor         #222266
}

node Client {
     interface RequestUtills
     interface CombatScreen

}

node Server {
     interface GameController
     interface WeaponController
     interface ShipController
     interface SectionController
     interface CrewMemberController



CombatScreen -> WeaponController: List<Weapon> validation
WeaponController -> CombatScreen: List<boolean> succesfullShots

}

#+END_SRC

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



#+BEGIN_SRC plantuml :file combatSequence.png


[*] -right-> PENDING
PENDING -right-> ROUND
ROUND -down-> PLAYING
PLAYING -right-> FAILURE: <b> Not Accepted </b>\n by Server
PLAYING -left-> SUCCESSFULL_VALIDATION
PLAYING -> END_ROUND
END_ROUND -> changeState
changeState -> GEGNER_ANTWORT




SUCCESSFULL_VALIDATION: List<Boolean> shots
SUCCESSFULL_VALIDATION: [true, true]

GEGNER_ANTWORT:  "<List> Weapons, String Event"


#+END_SRC

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