From 40a95fa6539a917abcfa0ec4f61d5be69a15b232 Mon Sep 17 00:00:00 2001 From: LidamaoHub Date: Sat, 11 Nov 2023 14:48:24 +0800 Subject: [PATCH] user can't submit or reveal when battle was end --- packages/contracts/out/IWorld.sol/IWorld.json | 50 +++++------ packages/contracts/out/Loot.sol/MLoot.json | 28 +++---- .../contracts/out/Plugin.sol/MPlugin.json | 82 +++++++++---------- packages/contracts/out/User.sol/MUser.json | 28 +++---- .../src/systems/BattleForceSystem.sol | 2 + .../src/systems/BattlePrepareSystem.sol | 1 + .../contracts/src/systems/BattleSystem.sol | 4 +- packages/contracts/worlds.json | 4 +- 8 files changed, 100 insertions(+), 99 deletions(-) diff --git a/packages/contracts/out/IWorld.sol/IWorld.json b/packages/contracts/out/IWorld.sol/IWorld.json index 0c0a86e7..bda29724 100644 --- a/packages/contracts/out/IWorld.sol/IWorld.json +++ b/packages/contracts/out/IWorld.sol/IWorld.json @@ -3912,16 +3912,16 @@ 119088, 119076, 71348, - 130409, - 130318, - 130302, - 130305, - 130357, - 174067, - 130347, - 130336, + 130436, + 130345, + 130329, + 130332, + 130384, + 174094, + 130374, + 130363, 64435, - 127575, + 127602, 64393, 64426, 64399, @@ -3932,22 +3932,22 @@ "nameLocation": "798:6:169", "scope": 119346, "usedErrors": [ - 127540, - 127546, - 127548, - 127550, - 127556, - 127562, - 127568, - 127574, - 174036, - 174040, - 174046, - 174050, - 174054, - 174058, - 174062, - 174066 + 127567, + 127573, + 127575, + 127577, + 127583, + 127589, + 127595, + 127601, + 174063, + 174067, + 174073, + 174077, + 174081, + 174085, + 174089, + 174093 ] } ], diff --git a/packages/contracts/out/Loot.sol/MLoot.json b/packages/contracts/out/Loot.sol/MLoot.json index bc7b1bc9..21dbe8ef 100644 --- a/packages/contracts/out/Loot.sol/MLoot.json +++ b/packages/contracts/out/Loot.sol/MLoot.json @@ -1636,34 +1636,34 @@ "id": 120387, "exportedSymbols": { "Address": [ - 131946 + 131973 ], "Base64": [ 119403 ], "Context": [ - 131968 + 131995 ], "ERC165": [ - 131992 + 132019 ], "ERC721": [ 72425 ], "IERC165": [ - 174273 + 174300 ], "IERC20": [ 71498 ], "IERC721": [ - 131571 + 131598 ], "IERC721Metadata": [ - 131616 + 131643 ], "IERC721Receiver": [ - 131589 + 131616 ], "MLoot": [ 120386 @@ -1672,10 +1672,10 @@ 120834 ], "Math": [ - 132858 + 132885 ], "SignedMath": [ - 132963 + 132990 ], "Strings": [ 72654 @@ -14325,11 +14325,11 @@ 120386, 120834, 72425, - 131616, - 131571, - 131992, - 174273, - 131968, + 131643, + 131598, + 132019, + 174300, + 131995, 120637 ], "name": "MLoot", diff --git a/packages/contracts/out/Plugin.sol/MPlugin.json b/packages/contracts/out/Plugin.sol/MPlugin.json index 19e5f6b6..b34aaeae 100644 --- a/packages/contracts/out/Plugin.sol/MPlugin.json +++ b/packages/contracts/out/Plugin.sol/MPlugin.json @@ -217,13 +217,13 @@ "id": 120930, "exportedSymbols": { "Loot": [ - 125239 + 125266 ], "MPlugin": [ 120929 ], "User": [ - 125200 + 125227 ] }, "nodeType": "SourceUnit", @@ -250,7 +250,7 @@ "file": "@systems/library/Interface.sol", "nameLocation": "-1:-1:-1", "scope": 120930, - "sourceUnit": 125240, + "sourceUnit": 125267, "symbolAliases": [ { "foreign": { @@ -258,7 +258,7 @@ "name": "User", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "66:4:174", "typeDescriptions": {} }, @@ -270,7 +270,7 @@ "name": "Loot", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "72:4:174", "typeDescriptions": {} }, @@ -550,7 +550,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" }, "typeName": { @@ -560,13 +560,13 @@ "id": 120862, "name": "User", "nodeType": "IdentifierPath", - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "389:4:174" }, - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "389:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" } }, @@ -600,10 +600,10 @@ "name": "User", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "401:4:174", "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_User_$125200_$", + "typeIdentifier": "t_type$_t_contract$_User_$125227_$", "typeString": "type(contract User)" } }, @@ -618,7 +618,7 @@ "src": "401:17:174", "tryCall": false, "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" } }, @@ -642,7 +642,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" }, "typeName": { @@ -652,13 +652,13 @@ "id": 120869, "name": "Loot", "nodeType": "IdentifierPath", - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "428:4:174" }, - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "428:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" } }, @@ -692,10 +692,10 @@ "name": "Loot", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "440:4:174", "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_Loot_$125239_$", + "typeIdentifier": "t_type$_t_contract$_Loot_$125266_$", "typeString": "type(contract Loot)" } }, @@ -710,7 +710,7 @@ "src": "440:17:174", "tryCall": false, "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" } }, @@ -812,7 +812,7 @@ "referencedDeclaration": 120864, "src": "503:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" } }, @@ -823,7 +823,7 @@ "lValueRequested": false, "memberName": "mint", "nodeType": "MemberAccess", - "referencedDeclaration": 125194, + "referencedDeclaration": 125221, "src": "503:9:174", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$returns$__$", @@ -880,7 +880,7 @@ "referencedDeclaration": 120871, "src": "529:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" } }, @@ -891,7 +891,7 @@ "lValueRequested": false, "memberName": "mint", "nodeType": "MemberAccess", - "referencedDeclaration": 125233, + "referencedDeclaration": 125260, "src": "529:9:174", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$returns$__$", @@ -970,7 +970,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" }, "typeName": { @@ -980,13 +980,13 @@ "id": 120901, "name": "User", "nodeType": "IdentifierPath", - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "643:4:174" }, - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "643:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" } }, @@ -1020,10 +1020,10 @@ "name": "User", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 125200, + "referencedDeclaration": 125227, "src": "655:4:174", "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_User_$125200_$", + "typeIdentifier": "t_type$_t_contract$_User_$125227_$", "typeString": "type(contract User)" } }, @@ -1038,7 +1038,7 @@ "src": "655:17:174", "tryCall": false, "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" } }, @@ -1062,7 +1062,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" }, "typeName": { @@ -1072,13 +1072,13 @@ "id": 120908, "name": "Loot", "nodeType": "IdentifierPath", - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "682:4:174" }, - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "682:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" } }, @@ -1112,10 +1112,10 @@ "name": "Loot", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 125239, + "referencedDeclaration": 125266, "src": "694:4:174", "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_Loot_$125239_$", + "typeIdentifier": "t_type$_t_contract$_Loot_$125266_$", "typeString": "type(contract Loot)" } }, @@ -1130,7 +1130,7 @@ "src": "694:17:174", "tryCall": false, "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" } }, @@ -1168,7 +1168,7 @@ "referencedDeclaration": 120910, "src": "721:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_Loot_$125239", + "typeIdentifier": "t_contract$_Loot_$125266", "typeString": "contract Loot" } }, @@ -1179,7 +1179,7 @@ "lValueRequested": false, "memberName": "revealNFT", "nodeType": "MemberAccess", - "referencedDeclaration": 125238, + "referencedDeclaration": 125265, "src": "721:14:174", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", @@ -1236,7 +1236,7 @@ "referencedDeclaration": 120903, "src": "759:4:174", "typeDescriptions": { - "typeIdentifier": "t_contract$_User_$125200", + "typeIdentifier": "t_contract$_User_$125227", "typeString": "contract User" } }, @@ -1247,7 +1247,7 @@ "lValueRequested": false, "memberName": "revealNFT", "nodeType": "MemberAccess", - "referencedDeclaration": 125199, + "referencedDeclaration": 125226, "src": "759:14:174", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", diff --git a/packages/contracts/out/User.sol/MUser.json b/packages/contracts/out/User.sol/MUser.json index 619548ac..3cabc635 100644 --- a/packages/contracts/out/User.sol/MUser.json +++ b/packages/contracts/out/User.sol/MUser.json @@ -1426,31 +1426,31 @@ "id": 121589, "exportedSymbols": { "Address": [ - 131946 + 131973 ], "Base64": [ 119403 ], "Context": [ - 131968 + 131995 ], "ERC165": [ - 131992 + 132019 ], "ERC721": [ 72425 ], "IERC165": [ - 174273 + 174300 ], "IERC721": [ - 131571 + 131598 ], "IERC721Metadata": [ - 131616 + 131643 ], "IERC721Receiver": [ - 131589 + 131616 ], "MRandom": [ 120834 @@ -1459,10 +1459,10 @@ 121588 ], "Math": [ - 132858 + 132885 ], "SignedMath": [ - 132963 + 132990 ], "Strings": [ 72654 @@ -9919,11 +9919,11 @@ 121588, 120834, 72425, - 131616, - 131571, - 131992, - 174273, - 131968 + 131643, + 131598, + 132019, + 174300, + 131995 ], "name": "MUser", "nameLocation": "172:5:175", diff --git a/packages/contracts/src/systems/BattleForceSystem.sol b/packages/contracts/src/systems/BattleForceSystem.sol index d7f758eb..d9606e0b 100644 --- a/packages/contracts/src/systems/BattleForceSystem.sol +++ b/packages/contracts/src/systems/BattleForceSystem.sol @@ -13,6 +13,8 @@ import {Position} from "./Common.sol"; contract BattleForceSystem is System { function forceEnd(uint256 _battleId) external { + require(!BattleList.getIsEnd(_battleId),"battel already end"); + BattleListData memory battle = BattleList.get(_battleId); require(_msgSender() == battle.attacker || _msgSender() == battle.defender, "not in battle"); require(block.timestamp - battle.endTimestamp > BattleConfig.getMaxTimeLimit(BATTLE_CONFIG_KEY), "battle not timeout"); diff --git a/packages/contracts/src/systems/BattlePrepareSystem.sol b/packages/contracts/src/systems/BattlePrepareSystem.sol index 7c3126aa..b1b572a5 100644 --- a/packages/contracts/src/systems/BattlePrepareSystem.sol +++ b/packages/contracts/src/systems/BattlePrepareSystem.sol @@ -81,6 +81,7 @@ contract BattlePrepareSystem is System { function confirmBattle(bytes32 _buffHash, uint256 _battleId) external { // 战斗是否有用户,用户是否在当前战斗//战斗是否结束//是否已超时 + require(!BattleList.getIsEnd(_battleId),"battel already end"); BattleListData memory battle = BattleList.get(_battleId); diff --git a/packages/contracts/src/systems/BattleSystem.sol b/packages/contracts/src/systems/BattleSystem.sol index 1c2e8c32..6d777de1 100644 --- a/packages/contracts/src/systems/BattleSystem.sol +++ b/packages/contracts/src/systems/BattleSystem.sol @@ -14,6 +14,7 @@ contract BattleSystem is System { event BattleEnd(uint256 battleId, BattleEndType endType, address winner); function revealBattle(uint256 _battleId, bytes32 _action, uint256 _arg, bytes32 _nonce) external { + require(!BattleList.getIsEnd(_battleId),"battel already end"); require(_action == bytes32("attack") || _action == bytes32("escape"), "invalid action"); // check battle BattleListData memory battle = BattleList.get(_battleId); @@ -60,11 +61,8 @@ contract BattleSystem is System { } else { escapeAndAttack(_battleId, battle); } - if (!BattleList.getIsEnd(_battleId)) { // 如果战斗还没结束 - // console.log(" round end "); - // emit BattleEnd(_battleId, BattleEndType.RoundEnd, address(0)); BattleList.setDefenderState(_battleId, BattleState.Inited); BattleList.setAttackerState(_battleId, BattleState.Inited); if (BattleList.getAttackerHP(_battleId) == 0 || BattleList.getDefenderHP(_battleId) == 0) { diff --git a/packages/contracts/worlds.json b/packages/contracts/worlds.json index 583bb23a..fddb214d 100644 --- a/packages/contracts/worlds.json +++ b/packages/contracts/worlds.json @@ -7,8 +7,8 @@ "address": "0x06C1aAfcE623554950bc49c28B64398D0Eb5fa34" }, "33784": { - "address": "0xd4B2485697e09CD5D40cd45A63cCD505A39E500a", - "blockNumber": 336952 + "address": "0x97D9A81b61bE843968a68fB75aeF2196cB636AbD", + "blockNumber": 337282 }, "421613": { "address": "0x2Bc1034975c3df48D6f3026802f372677844b85d",