Repository navigation
Let monster skills summon their adds #3274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/NosCore.GameObject/Services/BattleService/SummonService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // __ _ __ __ ___ __ ___ ___ | ||
| // | \| |/__\ /' _/ / _//__\| _ \ __| | ||
| // | | ' | \/ |`._`.| \_| \/ | v / _| | ||
| // |_|\__|\__/ |___/ \__/\__/|_|_\___| | ||
| // | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using NosCore.Data.Enumerations.Buff; | ||
| using NosCore.Data.StaticEntities; | ||
| using NosCore.GameObject.Ecs.Extensions; | ||
| using NosCore.GameObject.Ecs.Interfaces; | ||
| using NosCore.GameObject.Infastructure; | ||
| using NosCore.Networking; | ||
|
|
||
| namespace NosCore.GameObject.Services.BattleService; | ||
|
|
||
| public interface ISummonService | ||
| { | ||
| // Spawns, on the source's cell, every monster its summon cards call for. | ||
| Task SummonAsync(IAliveEntity source, IEnumerable<BCardDto> cards); | ||
| } | ||
|
|
||
| public sealed class SummonService(List<NpcMonsterDto> npcMonsters, IRandomProvider random) : ISummonService, ISingletonService | ||
| { | ||
| public Task SummonAsync(IAliveEntity source, IEnumerable<BCardDto> cards) | ||
| { | ||
| var summons = new List<NpcMonsterDto>(); | ||
| foreach (var card in cards) | ||
| { | ||
| var count = card.Effect() switch | ||
| { | ||
| BCardEffect.SummonsSummonUponDeath or BCardEffect.SummonsSummons => card.FirstData, | ||
| BCardEffect.SummonsSummonUponDeathChance or BCardEffect.SummonsSummonningChance | ||
| => random.Next(0, 100) < card.FirstData ? 1 : 0, | ||
| _ => 0, | ||
| }; | ||
| if (count <= 0 || npcMonsters.Find(m => m.NpcMonsterVNum == card.SecondData) is not { } summoned) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| summons.AddRange(Enumerable.Repeat(summoned, count)); | ||
| } | ||
|
|
||
| if (summons.Count == 0 || source.MapInstance == null) | ||
| { | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| return source.OnMapAsync(async () => | ||
| { | ||
| var map = source.MapInstance; | ||
| foreach (var npcMonster in summons) | ||
| { | ||
| var monster = map.SpawnMonster(npcMonster, source.PositionX, source.PositionY, true); | ||
| await map.SendPacketAsync(monster.GenerateIn()); | ||
| } | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.