package Ġcom . template . flows Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġcom . template . contracts . Board Contract Ċ import Ġcom . template . states . Board State Ċ import Ġnet . cord a . core . contracts .* Ċ import Ġnet . cord a . core . contracts . Requirements . using Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . node . services . query By Ċ import Ġnet . cord a . core . node . services . vault . Query Criteria Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . transactions . Transaction Builder Ċ import Ġnet . cord a . core . utilities . Progress Tracker Ċ Ċ // Ġ********* Ċ // Ġ* ĠFlow s Ġ* Ċ // Ġ********* Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠEnd Game Flow ( val Ġlinear Id : ĠUnique Identifier ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġprogress Tracker Ġ= ĠProgress Tracker () ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĊĠĠĠĠĠĠĠ Ġprintln (" GAME ĠOVER ") ĊĊĠĠĠĠĠĠĠ Ġval Ġnot ary Ġ= Ġservice Hub . network Map Cache . not ary Id entities . single () ĊĊĠĠĠĠĠĠĠ Ġval Ġquery Criteria Ġ= ĠQuery Criteria . Linear State Query Criteria ( linear Id Ġ= ĠlistOf ( linear Id )) ĊĠĠĠĠĠĠĠ Ġval Ġboard State Ref ToEnd Ġ= Ġservice Hub . vault Service . query By < Board State >( query Criteria ). states . single () ĊĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= ĠCommand ( Board Contract . Commands . End Game (), Ġboard State Ref ToEnd . state . data . participants . map Ġ{ Ġit . own ing Key Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġtx Builder Ġ= ĠTransaction Builder ( not ary ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( board State Ref ToEnd ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( command ) ĊĠĠĠĠĠĠĠ Ġtx Builder . verify ( service Hub ) ĊĊĠĠĠĠĠĠĠ Ġval Ġother Player Party Ġ= Ġ( board State Ref ToEnd . state . data . participants . map Ġ{ it Ġas ĠParty } Ġ- Ġour Identity ). single () ĊĊĠĠĠĠĠĠĠ Ġval Ġp tx Ġ= Ġservice Hub . sign Initial Transaction ( tx Builder ) ĊĠĠĠĠĠĠĠ Ġval Ġtarget Session Ġ= Ġinitiate Flow ( other Player Party ) ĊĠĠĠĠĠĠĠ Ġval Ġst x Ġ= Ġsub Flow ( Collect Signatures Flow ( pt x , ĠlistOf ( target Session ))) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Final ity Flow ( st x , Ġtarget Session )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Initi ated By ( End Game Flow :: class ) Ċ class ĠEnd Game Flow Responder ( val Ġcounter party Session : ĠFlow Session ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Flow Ġ= Ġobject Ġ: ĠSign Transaction Flow ( counter party Session ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcheck Transaction ( st x : ĠSigned Transaction ) Ġ= Ġrequire That Ġ{} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġtx We Just Signed Id Ġ= Ġsub Flow ( signed Transaction Flow ) ĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Receive Final ity Flow ( counter party Session , Ġtx We Just Signed Id . id )) ĊĠĠĠ Ġ} Ċ } Ċ