Skip to content

Commit 07e98d6

Browse files
authored
Merge pull request #181 from eesast/dev
gai
2 parents abf954e + 9e440dc commit 07e98d6

5 files changed

Lines changed: 33 additions & 30 deletions

File tree

docs/规则.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
**算力产出**:基础 1 点/秒,每个已占领算力中心 +2 点/秒
100100

101101
**被攻击**
102-
-30 秒工厂处于**无敌状态**,不受任何伤害
102+
-20 秒工厂处于**无敌状态**,不受任何伤害
103103
- 实际伤害 = `Max(ATK − Robust, 1)`
104104
- 攻击方获得 `伤害量` 分(等于工厂实际损失的血量)
105105
- 工厂被攻击后进入 1s 停摆(CanProduce 和 CanRecruit 均为 false)
@@ -129,7 +129,7 @@
129129
|:----:|:----:|:----:|:----:|
130130
| 血量 | 100 | 150 | 100 |
131131
| 攻击力 | 40 | 30 | 18 |
132-
| 攻击范围 | 1000 | 1000 | 1000 |
132+
| 攻击范围 | 1500 | 1500 | 1500 |
133133
| 防御力 | 10 | 15 | 8 |
134134
| 视野范围 | 7000 (7格) | 5000 (5格) | 5000 (5格) |
135135
| 负载上限 | 5 | 5 | 5 |

logic/Gaming/ActionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public bool Attack(Character character, Factory gameobj)
309309
// 前7分钟工厂不掉血
310310
if (game.NowTime() < GameData.FactoryInvulnerableTimeMs)
311311
{
312-
LogicLogging.logger.LogDebug("Factory is invulnerable in the first 7 minutes!");
312+
LogicLogging.logger.LogDebug("Factory is invulnerable in the first 20 seconds!");
313313
return false;
314314
}
315315

logic/Gaming/Game.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -252,29 +252,22 @@ public bool Attack(long teamId, long playerId)
252252
return false;
253253
}
254254
int attackRange = (int)character.AttackSize.GetValue();
255+
IGameObj? bestTarget = null;
256+
long bestDist = long.MaxValue;
257+
258+
// 遍历范围内所有敌方角色
255259
var enemies = gameMap.CharacterInTheRangeNotTeamID(character.Position, attackRange, character.TeamID.Get());
256-
if (enemies != null && enemies.Count > 0)
260+
if (enemies != null)
257261
{
258-
Character nearest = null;
259-
long bestDist = long.MaxValue;
260262
foreach (var e in enemies)
261263
{
262264
if (e == null || e.IsRemoved || e.HP <= 0) continue;
263265
long d = (long)XY.DistanceCeil3(e.Position, character.Position);
264-
if (d < bestDist)
265-
{
266-
bestDist = d;
267-
nearest = e;
268-
}
269-
}
270-
if (nearest != null)
271-
{
272-
return actionManager.Attack(character, nearest);
266+
if (d < bestDist) { bestDist = d; bestTarget = e; }
273267
}
274268
}
275269

276-
Factory? enemyFactory = null;
277-
long bestFactoryDist = long.MaxValue;
270+
// 遍历范围内所有敌方工厂
278271
var factoryObjs = gameMap.GameObjDict[GameObjType.FACTORY].ToNewList();
279272
if (factoryObjs != null)
280273
{
@@ -283,14 +276,17 @@ public bool Attack(long teamId, long playerId)
283276
if (obj is not Factory f || f.TeamID.Get() == character.TeamID.Get() || f.HP <= 0) continue;
284277
if (!GameData.IsInTheRange(f.Position, character.Position, attackRange)) continue;
285278
long d = (long)XY.DistanceCeil3(f.Position, character.Position);
286-
if (d < bestFactoryDist) { bestFactoryDist = d; enemyFactory = f; }
279+
if (d < bestDist) { bestDist = d; bestTarget = f; }
287280
}
288281
}
289-
if (enemyFactory != null)
290-
{
291-
return actionManager.Attack(character, enemyFactory);
292-
}
293-
LogicLogging.logger.LogWarning($"Attack failed: No valid targets in range for character of team {teamId} player {playerId}.");
282+
283+
if (bestTarget is Character targetChar)
284+
return actionManager.Attack(character, targetChar);
285+
if (bestTarget is Factory targetFac)
286+
return actionManager.Attack(character, targetFac);
287+
288+
int factoryCount = gameMap.GameObjDict.TryGetValue(GameObjType.FACTORY, out var flist) ? flist.ToNewList()?.Count ?? -1 : -1;
289+
LogicLogging.logger.LogWarning($"Attack failed: No valid targets in range for character of team {teamId} player {playerId}. pos=({character.Position.x},{character.Position.y}) range={attackRange} factoryCount={factoryCount}");
294290
return false;
295291
}
296292

logic/Preparation/Utility/GameData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class GameData
2727

2828
public const int MaxRobust = 50;
2929
public const int MaxEfficiency = 10;
30-
public const int MaxHP = 300;
30+
public const int MaxHP = 10000;
3131
public const int MaxCost = 2;
3232
public const int MaxATKSize = 3 * NumOfPosGridPerCell;
3333
public const int MaxATKPower = 100;
@@ -39,7 +39,7 @@ public static class GameData
3939

4040
public const int FactoryScore = 20000;
4141
public const int FactoryDisableTimeMs = 10_00;
42-
public const int FactoryInvulnerableTimeMs = 30 * 1000; // 前30秒工厂不掉血
42+
public const int FactoryInvulnerableTimeMs = 20 * 1000; // 前20秒工厂不掉血
4343

4444
// Score multipliers for combat
4545
public const int CharacterDamageScoreMultiplier = 20;
@@ -58,7 +58,7 @@ public static class GameData
5858

5959
public const int DroneHP = 100;
6060
public const int DroneCost = 50;
61-
public const int DroneATKsize = 1000;
61+
public const int DroneATKsize = 1500;
6262
public const int DroneATKpower = 40;
6363
public const int DroneLoad = 5;
6464
public const int DroneRobust = 10;
@@ -68,7 +68,7 @@ public static class GameData
6868

6969
public const int AutonomouCarHP = 100;
7070
public const int AutonomouCarCost = 50;
71-
public const int AutonomouCarATKsize = 1000;
71+
public const int AutonomouCarATKsize = 1500;
7272
public const int AutonomouCarATKpower = 18;
7373
public const int AutonomouCarLoad = 5;
7474
public const int AutonomouCarRobust = 8;
@@ -78,7 +78,7 @@ public static class GameData
7878

7979
public const int RobotHP = 150;
8080
public const int RobotCost = 50;
81-
public const int RobotATKsize = 1000;
81+
public const int RobotATKsize = 1500;
8282
public const int RobotATKpower = 30;
8383
public const int RobotLoad = 5;
8484
public const int RobotRobust = 15;

logic/Server/RpcServices.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,21 @@ public override Task<BoolRes> Attack(AttackMsg request, ServerCallContext contex
318318
GameServerLogging.logger.LogDebug(
319319
$"TRY Attack: Player {request.PlayerId} from Team {request.TeamId} attacking Player {request.AttackedPlayerId} from Team {request.AttackedTeamId}");
320320
BoolRes boolRes = new();
321-
if (request.AttackedTeamId > 0 && request.AttackedPlayerId == 0)
321+
if (request.AttackedTeamId > 0 && request.AttackedPlayerId > 0)
322322
{
323-
// 指定攻击工厂:跳过自动索敌,直接打目标工厂
323+
// 指定攻击角色:进攻指定队伍的指定玩家角色(暂用自动索敌,后续可扩展)
324+
boolRes.ActSuccess = game.Attack(
325+
request.TeamId, request.PlayerId);
326+
}
327+
else if (request.AttackedTeamId > 0)
328+
{
329+
// 指定攻击工厂:attacked_team_id > 0 且 attacked_player_id == 0
324330
boolRes.ActSuccess = game.AttackFactory(
325331
request.TeamId, request.PlayerId, request.AttackedTeamId);
326332
}
327333
else
328334
{
335+
// 未指定目标:自动索敌(最近敌方角色或工厂)
329336
boolRes.ActSuccess = game.Attack(
330337
request.TeamId, request.PlayerId);
331338
}

0 commit comments

Comments
 (0)