diff --git a/AlgebraicDataflowArchitectureModel/models/OnlineBattleGame2.model b/AlgebraicDataflowArchitectureModel/models/OnlineBattleGame2.model new file mode 100644 index 0000000..4012b23 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/models/OnlineBattleGame2.model @@ -0,0 +1,33 @@ +channel Signup { + out accounts(adb:Map, signUp(aid:Str, name:Str)) = insert(adb, aid, {"name": name, "point": 0}) +} + +channel ChangeName(aid:Str) { + out accounts.{aid}.name(prev_name:Str, changeName(name)) = name +} + +channel CreateRoom { + out rooms(rdb:Map, createRoom(rid:Str)) = insert(rdb, rid, {"members": nil, "battle": false}) +} + +channel AddRoomMember(rid:Str) { + out rooms.{rid}.members(mList:List, addRoomMember(id:Str)) = append(mList, {"id": id}) +} + +channel Battle(rid:Str) { + out rooms.{rid}.battle(prev_result, battle(result:Bool)) = result +} + +channel RoomName(rid:Str, mno:Int) { + in rooms.{rid}.members.{mno}.id(prev_mid:Str, sync(mid, name)) = mid + in accounts.{mid}.name(prev_name:Str, sync(mid, name)) = name + out rooms.{rid}.members.{mno}.name(prev_name:Str, sync(mid, name)) = name +} + +channel RoomResult(rid:Str) { + in rooms.{rid}.battle(prev_result, sync2(result, mid)) = result + sub RoomResult2(mno:Int) { + in rooms.{rid}.members.{mno}.id(prev_mid:Str, sync2(result, mid)) = mid + out accounts.{mid}.point(prev_point:Int, sunc2(result, mid)) = if(result, prev_point + 1, prev_point) + } +}