Skip to content

Commit

Permalink
Add base party implementation (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyrossm authored Oct 2, 2023
1 parent 99ec07c commit ccea2de
Show file tree
Hide file tree
Showing 23 changed files with 2,024 additions and 8 deletions.
164 changes: 164 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@

[*]
charset = utf-8-bom
end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

# Microsoft .NET properties
csharp_new_line_before_catch = false
csharp_new_line_before_else = false
csharp_new_line_before_finally = false
csharp_new_line_before_open_brace = none
csharp_new_line_between_query_expression_clauses = false
csharp_preferred_modifier_order = protected, public, override, private, new, internal, static, async, virtual, sealed, abstract, extern, unsafe, volatile, readonly, required:suggestion
csharp_space_after_cast = true
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_var_elsewhere = false:none
csharp_style_var_for_built_in_types = false:suggestion
dotnet_naming_rule.constants_rule.import_to_resharper = as_predefined
dotnet_naming_rule.constants_rule.severity = warning
dotnet_naming_rule.constants_rule.style = all_upper_style
dotnet_naming_rule.constants_rule.symbols = constants_symbols
dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_constants_rule.severity = warning
dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style
dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols
dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_instance_fields_rule.severity = warning
dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style
dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols
dotnet_naming_rule.private_static_fields_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_static_fields_rule.severity = warning
dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style_1
dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined
dotnet_naming_rule.private_static_readonly_rule.severity = warning
dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style
dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols
dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True
dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field
dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
dotnet_naming_rule.unity_serialized_field_rule.severity = warning
dotnet_naming_rule.unity_serialized_field_rule.style = lower_camel_case_style
dotnet_naming_rule.unity_serialized_field_rule.symbols = unity_serialized_field_symbols
dotnet_naming_style.all_upper_style.capitalization = all_upper
dotnet_naming_style.all_upper_style.word_separator = _
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
dotnet_naming_style.lower_camel_case_style_1.capitalization = camel_case
dotnet_naming_style.lower_camel_case_style_1.required_prefix = _
dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
dotnet_naming_symbols.constants_symbols.applicable_kinds = field
dotnet_naming_symbols.constants_symbols.required_modifiers = const
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field
dotnet_naming_symbols.private_constants_symbols.required_modifiers = const
dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

# ReSharper properties
resharper_align_linq_query = true
resharper_align_multiline_parameter = true
resharper_allow_comment_after_lbrace = true
resharper_arguments_skip_single = true
resharper_autodetect_indent_settings = true
resharper_blank_lines_after_block_statements = 0
resharper_blank_lines_around_auto_property = 0
resharper_blank_lines_around_property = 0
resharper_braces_for_for = required
resharper_braces_for_foreach = required_for_multiline_statement
resharper_braces_for_ifelse = not_required
resharper_braces_for_lock = not_required
resharper_braces_for_while = required
resharper_braces_redundant = false
resharper_csharp_blank_lines_around_field = 0
resharper_csharp_blank_lines_around_invocable = 0
resharper_csharp_blank_lines_around_region = 0
resharper_csharp_blank_lines_inside_region = 0
resharper_csharp_insert_final_newline = true
resharper_csharp_max_line_length = 359
resharper_csharp_remove_blank_lines_near_braces_in_code = false
resharper_csharp_remove_blank_lines_near_braces_in_declarations = false
resharper_csharp_wrap_before_binary_opsign = true
resharper_csharp_wrap_ternary_expr_style = wrap_if_long
resharper_formatter_off_tag = @formatter:off
resharper_formatter_on_tag = @formatter:on
resharper_formatter_tags_enabled = true
resharper_instance_members_qualify_declared_in =
resharper_keep_existing_attribute_arrangement = true
resharper_keep_existing_declaration_block_arrangement = true
resharper_keep_existing_embedded_block_arrangement = true
resharper_keep_existing_enum_arrangement = true
resharper_keep_existing_initializer_arrangement = false
resharper_modifiers_order = protected public override private new internal static async virtual sealed abstract extern unsafe volatile readonly required
resharper_outdent_statement_labels = true
resharper_parentheses_non_obvious_operations = none, bitwise_and, bitwise_exclusive_or, bitwise_inclusive_or, bitwise, conditional_and
resharper_parentheses_redundancy_style = remove
resharper_place_expr_accessor_on_single_line = true
resharper_place_expr_method_on_single_line = true
resharper_place_expr_property_on_single_line = true
resharper_place_field_attribute_on_same_line = if_owner_is_single_line
resharper_place_record_field_attribute_on_same_line = true
resharper_place_simple_anonymousmethod_on_single_line = false
resharper_place_simple_embedded_statement_on_same_line = true
resharper_place_simple_initializer_on_single_line = false
resharper_space_within_single_line_array_initializer_braces = false
resharper_trailing_comma_in_multiline_lists = true
resharper_use_indent_from_vs = false
resharper_wrap_array_initializer_style = chop_always
resharper_wrap_object_and_collection_initializer_style = chop_always

# ReSharper inspection severities
resharper_arrange_redundant_parentheses_highlighting = hint
resharper_arrange_this_qualifier_highlighting = hint
resharper_arrange_type_member_modifiers_highlighting = hint
resharper_arrange_type_modifiers_highlighting = hint
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
resharper_built_in_type_reference_style_highlighting = hint
resharper_redundant_base_qualifier_highlighting = warning
resharper_suggest_var_or_type_built_in_types_highlighting = hint
resharper_suggest_var_or_type_elsewhere_highlighting = hint
resharper_suggest_var_or_type_simple_types_highlighting = hint
resharper_web_config_module_not_resolved_highlighting = warning
resharper_web_config_type_not_resolved_highlighting = warning
resharper_web_config_wrong_module_highlighting = warning

[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
indent_style = space
indent_size = 2

[{*.bash,*.sh,*.zsh}]
indent_style = space
indent_size = 2

[*.proto]
indent_style = space
indent_size = 2

[*.{appxmanifest,asax,ascx,aspx,axaml,build,c,c++,cc,cginc,compute,cp,cpp,cppm,cs,cshtml,cu,cuh,cxx,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,nuspec,paml,razor,resw,resx,shader,skin,tpp,usf,ush,vb,xaml,xamlx,xoml,xsd}]
indent_style = space
indent_size = 4
tab_width = 4
96 changes: 96 additions & 0 deletions Maple2.Model/Error/PartyError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

// ReSharper disable InconsistentNaming, IdentifierTypo

using System.ComponentModel;

namespace Maple2.Model.Error;

public enum PartyError : byte {
none = 0,
[Description("The party is full.")]
s_party_err_full = 2,
[Description("You are not the party leader.")]
s_party_err_not_chief = 4,
[Description("The party has already been made.")]
s_party_err_already = 5,
[Description("You cannot invite that player to the party.")]
s_party_err_not_exist = 7,
[Description("{0} declined the party invitation.")]
s_party_err_deny = 9,
[Description("You cannot invite yourself to a party.")]
s_party_err_myself = 11,
[Description("{0} failed to respond to your party invitation.")]
s_party_err_deny_by_timeout = 12,
[Description("That player cannot accept party invites at this time.")]
s_party_err_cannot_invite = 14,
[Description("{0} has already received a party request.")]
s_party_err_alreadyInvite = 15,
[Description("You did not meet the entry requirements.")]
s_party_err_fail_enterable_result = 16,
[Description("Your Level is lower than the minimum level requirement.")]
s_party_err_lack_level = 17,
[Description("Your Gear Score is lower than the minimum Gear Score requirement.")]
s_party_err_lack_gear_score = 18,
[Description("The party is full.")]
s_party_err_full_limit_player = 19,
[Description("{0} refused the party invitation.")]
s_party_err_deny_by_auto = 20,
[Description("{0} cannot accept party invitations right now. Please try again later.")]
s_party_err_deny_by_system = 21,
[Description("This recruitment listing has been deleted.")]
s_party_err_invalid_party = 22,
[Description("Recruitment listing outdated. Please refresh and try again.")]
s_party_err_invalid_chief = 23,
[Description("This recruitment listing has been deleted.")]
s_party_err_invalid_recruit = 24,
[Description("Recruitment listing outdated. Please refresh and try again.")]
s_party_err_wrong_party = 25,
[Description("Recruitment listing outdated. Please refresh and try again.")]
s_party_err_wrong_recruit = 26,
[Description("Not enough merets.")]
s_err_lack_merat = 27,
[Description("You already received a party invite.")]
s_party_err_inviteMe = 28,
[Description("You cannot reset the dungeon while a party member is still inside.")]
s_room_party_err_is_in_user = 29,
[Description("You cannot send a party invite while fighting a dungeon boss.")]
s_party_invite_boss_room = 30,
[Description("Party not found.")]
s_party_err_not_found = 31,
[Description("You requested to join {0}'s party.")]
s_party_request_invite = 32,
[Description("Another request is already in progress.")]
s_party_err_already_vote = 33,
[Description("Not enough party members to start a kick vote.")]
s_party_err_vote_need_more_people = 34,
[Description("Please wait before requesting another vote.")]
s_party_err_vote_cooldown = 35,
[Description("That can only be done while battling the boss of {0}.")]
s_party_err_vote_cannot_kick_vote = 36,
[Description("That can only be done while fighting in dungeons.")]
s_party_err_vote_cannot_kick_vote_only_dungeon = 37,
[Description("You cannot kick a party member while you are fighting a dungeon boss.")]
s_party_expel_boss_room = 38,
[Description("You cannot kick a player that is already in a Mushking Royale match.")]
s_party_expel_maple_survival_squad = 39,
[Description("Only the party leader can send the request.")]
s_dungeonMatch_error_isNotChief = 40,
[Description("A party member has disconnected.")]
s_dungeonMatch_error_hasOfflineUser = 41,
[Description("A party member is still in the dungeon.\nPlease try again after all party members have exited the dungeon.")]
s_dungeonMatch_error_insideDungeonUser = 42,
[Description("You're already matching for other content.")]
s_party_err_dungeon_match_another = 43,
[Description("Only the party leader can send the request.")]
s_party_err_isNotChief = 44,
[Description("A party member is offline.")]
s_party_err_hasOfflineUser = 45,
[Description("A party member is already playing Mushking Royale.")]
s_party_err_inside_survival = 46,
[Description("You're already matching for other content.")]
s_party_err_another_matching = 47,
[Description("A party member is queueing for solo Mushking Royale.")]
s_party_err_survival_has_solo_register = 48,
[Description("A Mushking Royale squad cannot have more than 4 players.")]
s_maple_survival_error_squad_register_over_count = 49,
}
64 changes: 64 additions & 0 deletions Maple2.Model/Game/Party/Party.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Maple2.Model.Metadata;
using Maple2.PacketLib.Tools;
using Maple2.Tools;
using Maple2.Tools.Extensions;

namespace Maple2.Model.Game;

public class Party : IByteSerializable {
private int capacity = Constant.PartyMaxCapacity;
public int Capacity {
get => capacity;
set {
capacity = Math.Clamp(value, Constant.PartyMinCapacity, Constant.PartyMaxCapacity);
}
}

public required int Id { get; init; }
public required long LeaderAccountId;
public required long LeaderCharacterId;
public required string LeaderName;
public long CreationTime;
public int DungeonId = 0;
public string MatchPartyName = "";
public int MatchPartyId = 0;
public bool IsMatching = false;
public bool RequireApproval = false;
public readonly ConcurrentDictionary<long, PartyMember> Members;

[SetsRequiredMembers]
public Party(int id, long leaderAccountId, long leaderCharacterId, string leaderName) {
Id = id;
LeaderAccountId = leaderAccountId;
LeaderCharacterId = leaderCharacterId;
LeaderName = leaderName;
CreationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

Members = new ConcurrentDictionary<long, PartyMember>();
}

[SetsRequiredMembers]
public Party(int id, PartyMember leader) : this(id, leader.AccountId, leader.CharacterId, leader.Name) { }

public void WriteTo(IByteWriter writer) {
writer.WriteBool(true); // joining from offline?
writer.WriteInt(Id);
writer.WriteLong(LeaderCharacterId);

byte memberCount = (byte) Members.Count;
writer.WriteByte(memberCount);
foreach (PartyMember member in Members.Values) {
writer.WriteBool(!member.Info.Online);
writer.WriteClass<PartyMember>(member);
member.WriteDungeonEligibility(writer);
}

writer.WriteBool(false); // unk bool
writer.WriteInt(DungeonId);
writer.WriteBool(false); // unk bool
}
}
9 changes: 9 additions & 0 deletions Maple2.Model/Game/Party/PartyInvite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Maple2.Model.Game;

public class PartyInvite {
public enum Response : byte {
Accept = 1,
RejectInvite = 9,
RejectTimeout = 12,
}
}
Loading

0 comments on commit ccea2de

Please sign in to comment.