Skip to content

Commit e7228cf

Browse files
authored
Merge branch 'eesast:dev' into dev
2 parents d7af24c + 18ec38b commit e7228cf

12 files changed

Lines changed: 2199 additions & 3 deletions

File tree

dependency/proto/Proto.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
<ItemGroup>
1010
<PackageReference Include="FrameRateTask" Version="1.2.0" />
11-
<PackageReference Include="Google.Protobuf" Version="3.30.2" />
12-
<PackageReference Include="Google.Protobuf.Tools" Version="3.30.2" />
11+
<PackageReference Include="Google.Protobuf" Version="3.33.2" />
12+
<PackageReference Include="Google.Protobuf.Tools" Version="3.33.2" />
1313
<PackageReference Include="Grpc" Version="2.46.6" />
1414
<PackageReference Include="Grpc.Core" Version="2.46.6" />
15-
<PackageReference Include="Grpc.Tools" Version="2.71.0">
15+
<PackageReference Include="Grpc.Tools" Version="2.76.0">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>

logic/Server/ArgumentOptions.cs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using CommandLine;
2+
using Preparation.Utility;
3+
4+
namespace Server
5+
{
6+
public class DefaultArgumentOptions
7+
{
8+
public const string FileName = "xxxxxxxxx";
9+
public const string Token = "xxxxxxxxx";
10+
public const string Url = "xxxxxxxxx";
11+
public const string MapResource = "xxxxxxxxx";
12+
}
13+
public class ArgumentOptions
14+
{
15+
[Option("ip", Required = false, HelpText = "Server listening ip")]
16+
public string IP { get; set; } = "0.0.0.0";
17+
18+
[Option('p', "port", Required = true, HelpText = "Server listening port")]
19+
public ushort ServerPort { get; set; } = 8888;
20+
21+
[Option("teamCount", Required = false, HelpText = "The number of teams, 4 by defualt")]
22+
public ushort TeamCount { get; set; } = 4;
23+
24+
[Option("CharacterNum", Required = false, HelpText = "The max number of Character, 6 by default")]
25+
public ushort CharacterCount { get; set; } = 6;
26+
27+
[Option('g', "gameTimeInSecond", Required = false, HelpText = "The time of the game in second, 10 minutes by default")]
28+
public uint GameTimeInSecond { get; set; } = GameData.GameDurationInSecond;
29+
30+
[Option("homeNum", Required = false, HelpText = "The number of Home , 1 by default")]
31+
public ushort HomeCount { get; set; } = 1;
32+
33+
[Option('f', "fileName", Required = false, HelpText = "The file to store playback file or to read file.")]
34+
public string FileName { get; set; } = "xxxxxxxxx";
35+
36+
[Option("notAllowSpectator", Required = false, HelpText = "Whether to allow a spectator to watch the game.")]
37+
public bool NotAllowSpectator { get; set; } = false;
38+
39+
[Option('b', "playback", Required = false, HelpText = "Whether open the server in a playback mode.")]
40+
public bool Playback { get; set; } = false;
41+
42+
[Option("playbackSpeed", Required = false, HelpText = "The speed of the playback, between 0.25 and 4.0")]
43+
public double PlaybackSpeed { get; set; } = 1.0;
44+
45+
[Option("resultOnly", Required = false, HelpText = "In playback mode to get the result directly")]
46+
public bool ResultOnly { get; set; } = false;
47+
48+
[Option('k', "token", Required = false, HelpText = "Web API Token")]
49+
public string Token { get; set; } = "xxxxxxxxx";
50+
51+
[Option('u', "url", Required = false, HelpText = "Web Url")]
52+
public string Url { get; set; } = "xxxxxxxxx";
53+
54+
[Option('m', "mapResource", Required = false, HelpText = "Map Resource Path")]
55+
public string MapResource { get; set; } = DefaultArgumentOptions.MapResource;
56+
57+
[Option("requestOnly", Required = false, HelpText = "Only send web requests")]
58+
public bool RequestOnly { get; set; } = false;
59+
60+
[Option("finalGame", Required = false, HelpText = "Whether it is the final game")]
61+
public bool FinalGame { get; set; } = false;
62+
63+
[Option("cheatMode", Required = false, HelpText = "Whether to open the cheat code")]
64+
public bool CheatMode { get; set; } = false;
65+
66+
[Option("resultFileName", Required = false, HelpText = "Result file name, saved as .json")]
67+
public string ResultFileName { get; set; } = "xxxxxxxxx";
68+
69+
[Option("startLockFile", Required = false, HelpText = "Whether to create a file that identifies whether the game has started")]
70+
public string StartLockFile { get; set; } = "114514";
71+
72+
[Option("mode", Required = false, HelpText = "Whether to run final competition. 0 本地玩,1 最终比赛,2 天梯")]
73+
public int Mode { get; set; } = 0;
74+
75+
[Option("loglevel", Required = false, HelpText = "Set the log level: 1=Error, 2=Warning, 3=Info, 4=Debug, 5=Trace")]
76+
public int LogLevel { get; set; } = 5; // 默认Trace级别
77+
78+
}
79+
}

logic/Server/CopyInfo.cs

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
using GameClass.GameObj;
2+
using GameClass.GameObj.Areas;
3+
using Preparation.Utility;
4+
using Protobuf;
5+
using Utility = Preparation.Utility;
6+
7+
namespace Server
8+
{
9+
public static class CopyInfo
10+
{
11+
public static MessageOfObj? Auto(GameObj gameObj, long time)
12+
{
13+
if (gameObj.IsRemoved == true)
14+
return null;
15+
switch (gameObj.Type)
16+
{
17+
case GameObjType.CHARACTER:
18+
return Character((Character)gameObj, time);
19+
case GameObjType.ECONOMY_RESOURCE:
20+
return EconomyResource((E_Resource)gameObj);
21+
case GameObjType.ADDITIONAL_RESOURCE:
22+
return AdditionResource((A_Resource)gameObj);
23+
case GameObjType.CONSTRUCTION:
24+
Construction construction = (Construction)gameObj;
25+
if (construction.ConstructionType == Utility.ConstructionType.BARRACKS)
26+
return Barracks(construction);
27+
else if (construction.ConstructionType == Utility.ConstructionType.SPRING)
28+
return Spring(construction);
29+
else if (construction.ConstructionType == Utility.ConstructionType.FARM)
30+
return Farm(construction);
31+
return null;
32+
case GameObjType.TRAP:
33+
if (gameObj is HOLE hole)
34+
return Traps(hole);
35+
else if (gameObj is Cage cage)
36+
return Traps(cage);
37+
return null;
38+
default: return null;
39+
}
40+
}
41+
42+
public static MessageOfObj? Auto(MessageOfNews news)
43+
{
44+
MessageOfObj objMsg = new()
45+
{
46+
NewsMessage = news
47+
};
48+
return objMsg;
49+
}
50+
private static MessageOfObj? Base(Base player, long time)
51+
{
52+
MessageOfObj msg = new()
53+
{
54+
TeamMessage = new()
55+
{
56+
TeamId = player.TeamID,
57+
PlayerId = player.PlayerID,
58+
Score = player.MoneyPool.Score,
59+
Energy = player.MoneyPool.Money,
60+
}
61+
};
62+
return msg;
63+
}
64+
65+
public static MessageOfObj? Auto(Base @base, long time)
66+
{
67+
return Base(@base, time);
68+
}
69+
private static MessageOfObj? Character(Character player, long time)
70+
{
71+
MessageOfObj msg = new()
72+
{
73+
CharacterMessage = new()
74+
{
75+
Guid = player.ID,
76+
77+
TeamId = player.TeamID,
78+
PlayerId = player.PlayerID,
79+
80+
CharacterType = Transformation.CharacterTypeToProto(player.CharacterType),
81+
82+
CharacterActiveState = Transformation.CharacterStateToProto(player.CharacterState1),
83+
84+
IsBlind = player.blind,
85+
BlindTime = player.BlindTime,
86+
IsStunned = player.stunned,
87+
StunnedTime = player.StunnedTime,
88+
IsInvisible = !player.visible,
89+
InvisibleTime = player.InvisibleTime,
90+
IsBurned = player.burned,
91+
BurnedTime = player.BurnedTime,
92+
HarmCut = player.HarmCut,
93+
HarmCutTime = player.HarmCutTime,
94+
95+
CharacterPassiveState = Transformation.CharacterStateToProto(player.CharacterState2),
96+
97+
X = player.Position.x,
98+
Y = player.Position.y,
99+
100+
FacingDirection = player.FacingDirection.Angle(),
101+
Speed = player.MoveSpeed,
102+
ViewRange = player.ViewRange,
103+
104+
CommonAttack = (int)player.AttackPower,
105+
// 待修改,Character.cs中没有CommonAttackCD
106+
CommonAttackCd = (int)(1 / player.ATKFrequency),
107+
CommonAttackRange = (int)player.AttackSize,
108+
109+
SkillAttackCd = player.skillCD,
110+
111+
EconomyDepletion = player.EconomyDepletion,
112+
KillScore = (int)player.GetCost(),
113+
114+
Hp = (int)player.HP,
115+
116+
// 待修改,Shield要分两类
117+
ShieldEquipment = (int)player.Shield, // 护盾装备
118+
ShoesEquipment = (int)player.Shoes, // 加成值
119+
ShoesTime = player.ShoesTime, // 包含所有速度加成的时间
120+
IsPurified = player.Purified,
121+
PurifiedTime = player.PurifiedTime,
122+
IsBerserk = player.IsBerserk,
123+
BerserkTime = player.BerserkTime,
124+
125+
AttackBuffNum = (int)player.CrazyManNum,
126+
AttackBuffTime = player.CrazyManTime,
127+
SpeedBuffTime = player.QuickStepTime,
128+
VisionBuffTime = player.WideViewTime,
129+
}
130+
};
131+
return msg;
132+
}
133+
134+
private static MessageOfObj EconomyResource(E_Resource economyresource)
135+
{
136+
MessageOfObj msg = new()
137+
{
138+
EconomyResourceMessage = new()
139+
{
140+
EconomyResourceState = Transformation.EconomyResourceStateToProto(economyresource.ERstate),
141+
EconomyResourceType = Transformation.EconomyResourceTypeToProto(economyresource.EResourceType),
142+
143+
X = economyresource.Position.x,
144+
Y = economyresource.Position.y,
145+
146+
Process = (10000 - (int)economyresource.HP) / 10000,
147+
Id = 0,
148+
}
149+
};
150+
return msg;
151+
}
152+
153+
private static MessageOfObj AdditionResource(A_Resource additionResource)
154+
{
155+
MessageOfObj msg = new()
156+
{
157+
AdditionResourceMessage = new()
158+
{
159+
AdditionResourceType = Transformation.AResourceToProto(additionResource.AResourceType),
160+
AdditionResourceState = Transformation.AResourceStateToProto(additionResource.ARstate),
161+
162+
X = additionResource.Position.x,
163+
Y = additionResource.Position.y,
164+
165+
Hp = (int)additionResource.HP,
166+
Id = 0,
167+
}
168+
};
169+
// Debugger.Output(additionResource, additionResource.Place.ToString()+" "+additionResource.Position.ToString());
170+
return msg;
171+
}
172+
173+
private static MessageOfObj Barracks(Construction construction)
174+
{
175+
MessageOfObj msg = new()
176+
{
177+
BarracksMessage = new()
178+
{
179+
X = construction.Position.x,
180+
Y = construction.Position.y,
181+
182+
Hp = (int)construction.HP,
183+
184+
TeamId = construction.TeamID,
185+
Id = 0,
186+
}
187+
};
188+
return msg;
189+
}
190+
191+
private static MessageOfObj Spring(Construction construction)
192+
{
193+
MessageOfObj msg = new()
194+
{
195+
SpringMessage = new()
196+
{
197+
X = construction.Position.x,
198+
Y = construction.Position.y,
199+
200+
Hp = (int)construction.HP,
201+
202+
TeamId = construction.TeamID,
203+
Id = 0,
204+
}
205+
};
206+
return msg;
207+
}
208+
209+
private static MessageOfObj Farm(Construction construction)
210+
{
211+
MessageOfObj msg = new()
212+
{
213+
FarmMessage = new()
214+
{
215+
X = construction.Position.x,
216+
Y = construction.Position.y,
217+
218+
Hp = (int)construction.HP,
219+
220+
TeamId = construction.TeamID,
221+
Id = 0,
222+
}
223+
};
224+
return msg;
225+
}
226+
227+
// private static MessageOfObj Traps(GameObj trap)
228+
// {
229+
// MessageOfObj msg = new()
230+
// {
231+
// TrapMessage = new()
232+
// {
233+
// TrapType = trap switch
234+
// {
235+
// HOLE _ => Protobuf.TrapType.Hole,
236+
// Cage _ => Protobuf.TrapType.Cage,
237+
// },
238+
239+
// X = trap.Position.x,
240+
// Y = trap.Position.y,
241+
242+
// TeamId = trap switch
243+
// {
244+
// HOLE t => t.TeamID.Get(),
245+
// Cage c => c.TeamID.Get(),
246+
// },
247+
// Id = 0,
248+
249+
// TrapValid = !trap.IsActivated.Get(),
250+
// }
251+
// };
252+
// return msg;
253+
// }
254+
private static MessageOfObj Traps(HOLE trap)
255+
{
256+
MessageOfObj msg = new()
257+
{
258+
TrapMessage = new()
259+
{
260+
TrapType = Protobuf.TrapType.Hole,
261+
262+
X = trap.Position.x,
263+
Y = trap.Position.y,
264+
265+
TeamId = trap.TeamID.Get(),
266+
Id = 0,
267+
268+
TrapValid = !trap.IsActivated.Get(),
269+
}
270+
};
271+
return msg;
272+
}
273+
274+
private static MessageOfObj Traps(Cage trap)
275+
{
276+
MessageOfObj msg = new()
277+
{
278+
TrapMessage = new()
279+
{
280+
TrapType = Protobuf.TrapType.Cage,
281+
282+
X = trap.Position.x,
283+
Y = trap.Position.y,
284+
285+
TeamId = trap.TeamID.Get(),
286+
Id = 0,
287+
288+
TrapValid = !trap.IsActivated.Get(),
289+
}
290+
};
291+
return msg;
292+
}
293+
}
294+
}

0 commit comments

Comments
 (0)