public void When_self_reference_should_not_appear_in_includes()
        {
            var alice = new Lover {
                Id = "alice"
            };

            //the narcissist
            alice.Loves = alice;


            var json = JsonConvert.SerializeObject(alice, settings);

            Assert.Equal(@"
{
    ""data"": {
        ""type"": ""lover"",
        ""id"": ""alice"",
        ""relationships"": {
            ""loves"": {
                ""data"": {
                    ""id"": ""alice"",
                    ""type"": ""lover""
                }
            }
        }
    }
}", json, JsonStringEqualityComparer.Instance);
        }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     theLover    = this;
     myRigidbody = GetComponent <Rigidbody>();
     startPos    = transform.position;
     parts       = GetComponentInChildren <ParticleSystem>();
     parte       = GetComponentInChildren <ParticleEmitter>();
 }
Пример #3
0
	// Use this for initialization
	void Start ()
	{
		theLover = this;
		myRigidbody = GetComponent<Rigidbody>();
		startPos = transform.position;
		parts = GetComponentInChildren<ParticleSystem>();
		parte = GetComponentInChildren<ParticleEmitter>();
	}
Пример #4
0
        public async Task <IActionResult> Add([FromForm] LoverPhotoAddResource loverPhotoAddResource)
        {
            IFormFile file = loverPhotoAddResource.File;

            if (file == null)   // 表单中必须包含图片文件
            {
                ModelState.AddModelError("loverPhotoAddResource", $"parameter {file} cannot be null");
                return(BadRequest(ModelState));
            }

            // 无法自动映射表单的Tags到对应的Tags集合属性, 所以手动处理一下, 读取key为Tags的值, 反序列化json
            // 元数据是json数组, 示例: [{"name": "value"}, {"name", "value2"}]
            // 表单中只能有一个tags键
            Request.Form.TryGetValue("tags", out StringValues tagsStrings);
            if (tagsStrings.Count > 1)
            {
                return(BadRequest());
            }
            if (tagsStrings.Count <= 0)
            {
                tagsStrings = new StringValues("[]");
            }
            IList <TagAddResource> tags =
                JsonConvert.DeserializeObject <IList <TagAddResource> >(tagsStrings.FirstOrDefault());

            loverPhotoAddResource.Tags = tags;

            LoverCloudUser user = await _userRepository.FindByIdAsync(this.GetUserId());

            Lover lover = user.Lover;

            LoverPhoto loverPhoto = _mapper.Map <LoverPhoto>(loverPhotoAddResource);

            // 生成 PhotoPhysicalPath 要用到 Uploader, 所以先设置 Uploader 的值
            loverPhoto.Uploader     = user;
            loverPhoto.Lover        = lover;
            loverPhoto.PhysicalPath = loverPhoto.GeneratePhotoPhysicalPath(file.GetFileSuffix());;
            loverPhoto.UpdateDate   = DateTime.Now;
            loverPhoto.PhotoUrl     = Url.LinkRelative("GetPhoto", new { id = loverPhoto.Id });
            // 添加到数据库
            _repository.Add(loverPhoto);
            if (!await _unitOfWork.SaveChangesAsync())
            {
                throw new Exception("数据保存失败");
            }
            // 保存图片文件
            await file.SaveToFileAsync(loverPhoto.PhysicalPath);

            LoverPhotoResource loverPhotoResource = _mapper.Map <LoverPhotoResource>(loverPhoto);
            ExpandoObject      result             = loverPhotoResource.ToDynamicObject()
                                                    .AddLinks(this, null, "photo", "GetPhoto", "DeleteLoverPhoto", "PartiallyUpdateLoverPhoto");

            return(CreatedAtRoute("AddLoverPhoto", result));
        }
        public void When_included_self_references_should_not_have_additional_include()
        {
            var alice = new Lover {
                Id = "alice"
            };
            var bob = new Lover {
                Id = "bob"
            };

            //the unrequited love
            alice.Loves = bob;
            bob.Loves   = bob;



            var json = JsonConvert.SerializeObject(alice, settings);

            Assert.Equal(@"
{
    ""data"": {
        ""type"": ""lover"",
        ""id"": ""alice"",
        ""relationships"": {
            ""loves"": {
                ""data"": {
                    ""id"": ""bob"",
                    ""type"": ""lover""
                }
            }
        }
    },
    ""included"": [
    {
        ""type"": ""lover"",
        ""id"": ""bob"",
        ""relationships"": {
            ""loves"": {
                ""data"": {
                    ""id"": ""bob"",
                    ""type"": ""lover""
                }
            }
        }
    }]
}", json, JsonStringEqualityComparer.Instance);
        }
        public async Task <IActionResult> Add([FromForm] LoverLogAddResource addResource)
        {
            LoverCloudUser user = await _userRepository.FindByIdAsync(this.GetUserId());

            Lover lover = user.Lover;

            LoverLog loverLog = _mapper.Map <LoverLog>(addResource);

            loverLog.Creater        = user;
            loverLog.Lover          = lover;
            loverLog.CreateDateTime = DateTime.Now;
            loverLog.LastUpdateTime = DateTime.Now;
            _repository.Add(loverLog);
            if (addResource.Photos != null)
            {
                foreach (var formFile in addResource.Photos)
                {
                    var photo = new LoverPhoto
                    {
                        Name           = formFile.FileName,
                        Uploader       = user,
                        Lover          = lover,
                        LoverLog       = loverLog,
                        PhotoTakenDate = DateTime.Now,
                    };
                    photo.PhysicalPath = photo.GeneratePhotoPhysicalPath(formFile.GetFileSuffix());
                    loverLog.LoverPhotos.Add(photo);
                    await formFile.SaveToFileAsync(photo.PhysicalPath);
                }
            }

            if (!await _unitOfWork.SaveChangesAsync())
            {
                return(NoContent());
            }

            LoverLogResource loverLogResource       = _mapper.Map <LoverLogResource>(loverLog);
            ExpandoObject    shapedLoverLogResource = loverLogResource.ToDynamicObject()
                                                      .AddLinks(
                this, null, "log", "GetLoverLog",
                "DeleteLoverLog", "PartiallyUpdateLoverLog");

            return(CreatedAtRoute("AddLoverLog", shapedLoverLogResource));
        }
Пример #7
0
        protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext context,
            OperationAuthorizationRequirement requirement,
            ILoverResource resource)
        {
            if (requirement.Name == Operations.Update.Name ||
                requirement.Name == Operations.Delete.Name)
            {
                if (string.IsNullOrEmpty(resource.LoverId))
                {
                    return;
                }
                Lover lover = await _loverRepository.FindByUserIdAsync(context.User.GetUserId());

                if (lover?.Id == resource.LoverId)
                {
                    context.Succeed(requirement);
                }
            }
        }
Пример #8
0
    private static long ColectingHearths(Space galaxy)
    {
        string loverData;
        long   sum = 0L;

        Coordinates coordinates = new Coordinates();
        Evil        evil        = new Evil();
        Lover       ivo         = new Lover();

        while ((loverData = Console.ReadLine()) != "Let the Force be with you")
        {
            evil = new Evil(new Coordinates(Console.ReadLine()));
            evil.RemoveStars(galaxy);

            ivo = new Lover(sum, new Coordinates(loverData));
            ivo.ColectingStars(galaxy, ivo.StarsColected);
            sum = ivo.StarsColected;     //<----------------------този ред липсваше!!!
        }
        return(ivo.StarsColected);
    }
Пример #9
0
        public async Task <IActionResult> PatchLoverRequest([FromRoute] string id, [FromBody] JsonPatchDocument <LoverRequestUpdateResource> loverRequestPatchDocument)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(BadRequest());
            }

            var loverRequestToUpdate = await _repository.FindByIdAsync(id);

            if (loverRequestToUpdate == null)
            {
                return(BadRequest($"找不到对应的 LoverRequest({id})"));
            }

            AuthorizationResult authorizationResult = await _authorizationService
                                                      .AuthorizeAsync(
                User,
                null,
                new SameUserRequirement(loverRequestToUpdate.ReceiverId));

            if (!(authorizationResult.Succeeded))
            {
                return(Forbid());
            }

            var loverRequestToUpdateResource = _mapper.Map <LoverRequestUpdateResource>(
                loverRequestToUpdate);

            loverRequestPatchDocument.ApplyTo(loverRequestToUpdateResource);
            _mapper.Map(loverRequestToUpdateResource, loverRequestToUpdate);

            //if (loverRequestToUpdate.LoverId != null) return BadRequest();

            if (loverRequestToUpdateResource.Succeed == true &&
                loverRequestToUpdate.LoverId == null &&
                loverRequestToUpdate.Receiver.Lover == null &&
                loverRequestToUpdate.Requester.Lover == null)
            {
                var users = new LoverCloudUser[]
                {
                    loverRequestToUpdate.Receiver,
                    loverRequestToUpdate.Requester
                };

                var lover = new Lover
                {
                    RegisterDate    = DateTime.Now,
                    LoverCloudUsers = users
                };
                loverRequestToUpdate.Lover = lover;
                _loverRepository.Add(lover);
            }
            else
            {
                return(BadRequest());
            }

            if (!await _unitOfWork.SaveChangesAsync())
            {
                throw new Exception("保存数据到数据库失败");
            }

            return(NoContent());
        }
Пример #10
0
            public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
            {
                //if (callId >= 43) //System.Console.WriteLine("Received " + callId);
                byte  readByte, readByte1, readByte2;
                sbyte readSByte, readSByte2;

                switch ((CustomRPC)callId)
                {
                case CustomRPC.SetMayor:
                    readByte = reader.ReadByte();
                    new Mayor(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetJester:
                    readByte = reader.ReadByte();
                    new Jester(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetSheriff:
                    readByte = reader.ReadByte();
                    new Sheriff(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetEngineer:
                    readByte = reader.ReadByte();
                    new Engineer(Utils.PlayerById(readByte));
                    break;


                case CustomRPC.SetJanitor:
                    new Janitor(Utils.PlayerById(reader.ReadByte()));

                    break;

                case CustomRPC.SetSwapper:
                    readByte = reader.ReadByte();
                    new Swapper(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetShifter:
                    readByte = reader.ReadByte();
                    new Shifter(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetInvestigator:
                    readByte = reader.ReadByte();
                    new Investigator(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetTimeLord:
                    readByte = reader.ReadByte();
                    new TimeLord(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetTorch:
                    readByte = reader.ReadByte();
                    new Torch(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetDiseased:
                    readByte = reader.ReadByte();
                    new Diseased(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetFlash:
                    readByte = reader.ReadByte();
                    new Flash(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetMedic:
                    readByte = reader.ReadByte();
                    new Medic(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.SetMorphling:
                    readByte = reader.ReadByte();
                    new Morphling(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.LoveWin:
                    var winnerlover = Utils.PlayerById(reader.ReadByte());
                    Role.GetRole <Lover>(winnerlover).Win();
                    break;


                case CustomRPC.JesterLose:
                    foreach (var role in Role.AllRoles)
                    {
                        if (role.RoleType == RoleEnum.Jester)
                        {
                            ((Jester)role).Loses();
                        }
                    }

                    break;

                case CustomRPC.PhantomLose:
                    foreach (var role in Role.AllRoles)
                    {
                        if (role.RoleType == RoleEnum.Phantom)
                        {
                            ((Phantom)role).Loses();
                        }
                    }

                    break;


                case CustomRPC.GlitchLose:
                    foreach (var role in Role.AllRoles)
                    {
                        if (role.RoleType == RoleEnum.Glitch)
                        {
                            ((Glitch)role).Loses();
                        }
                    }

                    break;

                case CustomRPC.ShifterLose:
                    foreach (var role in Role.AllRoles)
                    {
                        if (role.RoleType == RoleEnum.Shifter)
                        {
                            ((Shifter)role).Loses();
                        }
                    }

                    break;

                case CustomRPC.ExecutionerLose:
                    foreach (var role in Role.AllRoles)
                    {
                        if (role.RoleType == RoleEnum.Executioner)
                        {
                            ((Executioner)role).Loses();
                        }
                    }

                    break;

                case CustomRPC.NobodyWins:
                    Role.NobodyWinsFunc();
                    break;

                case CustomRPC.SetCouple:
                    byte id             = reader.ReadByte();
                    byte id2            = reader.ReadByte();
                    bool lovingImpostor = reader.ReadBoolean();
                    var  lover1         = Utils.PlayerById(id);
                    var  lover2         = Utils.PlayerById(id2);

                    var roleLover1 = new Lover(lover1, false, lovingImpostor);
                    var roleLover2 = new Lover(lover2, lovingImpostor, lovingImpostor);

                    roleLover1.OtherLover = roleLover2;
                    roleLover2.OtherLover = roleLover1;

                    break;

                case CustomRPC.Start:
                    Utils.ShowDeadBodies = false;
                    Murder.KilledPlayers.Clear();
                    Role.NobodyWins = false;
                    RecordRewind.points.Clear();
                    KillButtonTarget.DontRevive = byte.MaxValue;
                    break;

                case CustomRPC.JanitorClean:
                {
                    readByte1 = reader.ReadByte();
                    var janitorPlayer = Utils.PlayerById(readByte1);
                    var janitorRole   = Role.GetRole <Janitor>(janitorPlayer);
                    readByte = reader.ReadByte();
                    var deadBodies = Object.FindObjectsOfType <DeadBody>();
                    foreach (var body in deadBodies)
                    {
                        if (body.ParentId == readByte)
                        {
                            Coroutines.Start(Coroutine.CleanCoroutine(body, janitorRole));
                        }
                    }
                    break;
                }

                case CustomRPC.EngineerFix:
                    var engineer = Utils.PlayerById(reader.ReadByte());
                    Role.GetRole <Engineer>(engineer).UsedThisRound = true;
                    break;


                case CustomRPC.FixLights:
                    var lights = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast <SwitchSystem>();
                    lights.ActualSwitches = lights.ExpectedSwitches;
                    break;

                case CustomRPC.SetExtraVotes:

                    var mayor     = Utils.PlayerById(reader.ReadByte());
                    var mayorRole = Role.GetRole <Mayor>(mayor);
                    mayorRole.ExtraVotes = reader.ReadBytesAndSize().ToList();
                    if (!mayor.Is(RoleEnum.Mayor))
                    {
                        mayorRole.VoteBank -= mayorRole.ExtraVotes.Count;
                    }

                    break;

                case CustomRPC.SetSwaps:
                    readSByte       = reader.ReadSByte();
                    SwapVotes.Swap1 =
                        MeetingHud.Instance.playerStates.FirstOrDefault(x => x.TargetPlayerId == readSByte);
                    readSByte2      = reader.ReadSByte();
                    SwapVotes.Swap2 =
                        MeetingHud.Instance.playerStates.FirstOrDefault(x => x.TargetPlayerId == readSByte2);
                    PluginSingleton <TownOfUs> .Instance.Log.LogMessage("Bytes received - " + readSByte + " - " +
                                                                        readSByte2);

                    break;

                case CustomRPC.Shift:
                    readByte1 = reader.ReadByte();
                    readByte2 = reader.ReadByte();
                    var shifter = Utils.PlayerById(readByte1);
                    var other   = Utils.PlayerById(readByte2);
                    PerformKillButton.Shift(Role.GetRole <Shifter>(shifter), other);
                    break;

                case CustomRPC.Rewind:
                    readByte = reader.ReadByte();
                    var TimeLordPlayer = Utils.PlayerById(readByte);
                    var TimeLordRole   = Role.GetRole <TimeLord>(TimeLordPlayer);
                    StartStop.StartRewind(TimeLordRole);
                    break;

                case CustomRPC.Protect:
                    readByte1 = reader.ReadByte();
                    readByte2 = reader.ReadByte();

                    var medic  = Utils.PlayerById(readByte1);
                    var shield = Utils.PlayerById(readByte2);
                    Role.GetRole <Medic>(medic).ShieldedPlayer = shield;
                    Role.GetRole <Medic>(medic).UsedAbility    = true;
                    break;

                case CustomRPC.RewindRevive:
                    readByte = reader.ReadByte();
                    RecordRewind.ReviveBody(Utils.PlayerById(readByte));
                    break;

                case CustomRPC.AttemptSound:
                    var medicId = reader.ReadByte();
                    readByte = reader.ReadByte();
                    StopKill.BreakShield(medicId, readByte, CustomGameOptions.ShieldBreaks);
                    break;

                case CustomRPC.SetGlitch:
                    var GlitchId     = reader.ReadByte();
                    var GlitchPlayer = Utils.PlayerById(GlitchId);
                    new Glitch(GlitchPlayer);
                    break;

                case CustomRPC.BypassKill:
                    var killer = Utils.PlayerById(reader.ReadByte());
                    var target = Utils.PlayerById(reader.ReadByte());

                    Utils.MurderPlayer(killer, target);
                    break;

                case CustomRPC.AssassinKill:
                    var toDie = Utils.PlayerById(reader.ReadByte());
                    AssassinKill.MurderPlayer(toDie);
                    Assassin.AssassinState.RemainingKills--;
                    AddButton.MaybeHideButtons();
                    break;

                case CustomRPC.Teleport:
                    byte teleports = reader.ReadByte();
                    Dictionary <byte, Vector2> coordinates = new Dictionary <byte, Vector2>();
                    for (int i = 0; i < teleports; i++)
                    {
                        byte    playerId = reader.ReadByte();
                        Vector2 location = reader.ReadVector2();
                        coordinates.Add(playerId, location);
                    }
                    Teleporter.TeleportPlayersToCoordinates(coordinates);
                    break;

                case CustomRPC.Conceal:
                {
                    PlayerControl concealer = Utils.PlayerById(reader.ReadByte());
                    PlayerControl concealed = Utils.PlayerById(reader.ReadByte());
                    Concealer     role      = Role.GetRole <Concealer>(concealer);
                    role.StartConceal(concealed);
                    break;
                }

                case CustomRPC.GoCovert:
                {
                    PlayerControl covert = Utils.PlayerById(reader.ReadByte());
                    Covert        role   = Role.GetRole <Covert>(covert);
                    role.GoCovert();
                    break;
                }

                case CustomRPC.SetMimic:
                    var glitchPlayer = Utils.PlayerById(reader.ReadByte());
                    var mimicPlayer  = Utils.PlayerById(reader.ReadByte());
                    var glitchRole   = Role.GetRole <Glitch>(glitchPlayer);
                    glitchRole.MimicTarget  = mimicPlayer;
                    glitchRole.IsUsingMimic = true;
                    Utils.Morph(glitchPlayer, mimicPlayer);
                    break;

                case CustomRPC.RpcResetAnim:
                    var animPlayer    = Utils.PlayerById(reader.ReadByte());
                    var theGlitchRole = Role.GetRole <Glitch>(animPlayer);
                    theGlitchRole.MimicTarget  = null;
                    theGlitchRole.IsUsingMimic = false;
                    Utils.Unmorph(theGlitchRole.Player);
                    break;

                case CustomRPC.GlitchWin:
                    var theGlitch = Role.AllRoles.FirstOrDefault(x => x.RoleType == RoleEnum.Glitch);
                    ((Glitch)theGlitch)?.Wins();
                    break;

                case CustomRPC.SetHacked:
                    var hackPlayer = Utils.PlayerById(reader.ReadByte());
                    if (hackPlayer.PlayerId == PlayerControl.LocalPlayer.PlayerId)
                    {
                        var glitch = Role.AllRoles.FirstOrDefault(x => x.RoleType == RoleEnum.Glitch);
                        ((Glitch)glitch)?.SetHacked(hackPlayer);
                    }

                    break;

                case CustomRPC.Investigate:
                {
                    var  seer          = Utils.PlayerById(reader.ReadByte());
                    var  otherPlayer   = Utils.PlayerById(reader.ReadByte());
                    bool successfulSee = reader.ReadByte() == 1;     // TODO: Can this be readBoolean()?
                    Seer role          = Role.GetRole <Seer>(seer);
                    role.Investigated.Add(otherPlayer.PlayerId, successfulSee);
                    role.ResetCooldownTimer();
                    break;
                }

                case CustomRPC.SetSeer:
                    new Seer(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.Morph:
                    var morphling   = Utils.PlayerById(reader.ReadByte());
                    var morphTarget = Utils.PlayerById(reader.ReadByte());
                    var morphRole   = Role.GetRole <Morphling>(morphling);
                    morphRole.TimeRemaining = CustomGameOptions.MorphlingDuration;
                    morphRole.MorphedPlayer = morphTarget;
                    break;

                case CustomRPC.SetExecutioner:
                    new Executioner(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetTarget:
                    var executioner = Utils.PlayerById(reader.ReadByte());
                    var exeTarget   = Utils.PlayerById(reader.ReadByte());
                    var exeRole     = Role.GetRole <Executioner>(executioner);
                    exeRole.target = exeTarget;
                    break;

                case CustomRPC.SetCamouflager:
                    new Camouflager(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.Camouflage:
                    var camouflager     = Utils.PlayerById(reader.ReadByte());
                    var camouflagerRole = Role.GetRole <Camouflager>(camouflager);
                    camouflagerRole.TimeRemaining = CustomGameOptions.CamouflagerDuration;
                    Utils.Camouflage();
                    break;

                case CustomRPC.SetSpy:
                    new Spy(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.ExecutionerToJester:
                    TargetColor.ExeToJes(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetSnitch:
                    new Snitch(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetMiner:
                    new Miner(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.Mine:
                    var ventId    = reader.ReadInt32();
                    var miner     = Utils.PlayerById(reader.ReadByte());
                    var minerRole = Role.GetRole <Miner>(miner);
                    var pos       = reader.ReadVector2();
                    var zAxis     = reader.ReadSingle();
                    PerformKill.SpawnVent(ventId, minerRole, pos, zAxis);
                    break;

                case CustomRPC.SetSwooper:
                    new Swooper(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.Swoop:
                    var swooper     = Utils.PlayerById(reader.ReadByte());
                    var swooperRole = Role.GetRole <Swooper>(swooper);
                    swooperRole.TimeRemaining = CustomGameOptions.SwoopDuration;
                    swooperRole.Swoop();
                    break;

                case CustomRPC.SetGrenadier:
                    new Grenadier(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.FlashGrenade:
                    PlayerControl grenadier     = Utils.PlayerById(reader.ReadByte());
                    Grenadier     grenadierRole = Role.GetRole <Grenadier>(grenadier);
                    grenadierRole.TimeRemaining = CustomGameOptions.GrenadeDuration;
                    grenadierRole.Flash();
                    break;

                case CustomRPC.SetTiebreaker:
                    new Tiebreaker(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetDrunk:
                    new Drunk(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetArsonist:
                    new Arsonist(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.Douse:
                    var arsonist     = Utils.PlayerById(reader.ReadByte());
                    var douseTarget  = Utils.PlayerById(reader.ReadByte());
                    var arsonistRole = Role.GetRole <Arsonist>(arsonist);
                    arsonistRole.DousedPlayers.Add(douseTarget.PlayerId);
                    arsonistRole.ResetCooldownTimer();
                    break;

                case CustomRPC.Ignite:
                    var theArsonist     = Utils.PlayerById(reader.ReadByte());
                    var theArsonistRole = Role.GetRole <Arsonist>(theArsonist);
                    global::TownOfUs.NeutralRoles.ArsonistMod.PerformKill.Ignite(theArsonistRole);
                    break;

                case CustomRPC.ArsonistWin:
                    var theArsonistTheRole = Role.AllRoles.FirstOrDefault(x => x.RoleType == RoleEnum.Arsonist);
                    ((Arsonist)theArsonistTheRole)?.Wins();
                    break;

                case CustomRPC.ArsonistLose:
                    foreach (var role in Role.AllRoles)
                    {
                        if (role.RoleType == RoleEnum.Arsonist)
                        {
                            ((Arsonist)role).Loses();
                        }
                    }

                    break;

                case CustomRPC.SetImpostor:
                    new Impostor(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetCrewmate:
                    new Crewmate(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SyncCustomSettings:
                    Rpc.ReceiveRpc(reader);
                    break;

                case CustomRPC.SetAltruist:
                    new Altruist(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetProphet:
                    new Prophet(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetCovert:
                    new Covert(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetBigBoi:
                    new BigBoiModifier(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.AltruistRevive:
                {
                    readByte1 = reader.ReadByte();
                    var altruistPlayer = Utils.PlayerById(readByte1);
                    var altruistRole   = Role.GetRole <Altruist>(altruistPlayer);
                    readByte = reader.ReadByte();
                    var theDeadBodies = Object.FindObjectsOfType <DeadBody>();
                    foreach (var body in theDeadBodies)
                    {
                        if (body.ParentId == readByte)
                        {
                            if (body.ParentId == PlayerControl.LocalPlayer.PlayerId)
                            {
                                Coroutines.Start(Utils.FlashCoroutine(altruistRole.Color,
                                                                      CustomGameOptions.ReviveDuration, 0.5f));
                            }

                            Coroutines.Start(
                                global::TownOfUs.CrewmateRoles.AltruistMod.Coroutine.AltruistRevive(body,
                                                                                                    altruistRole));
                        }
                    }

                    break;
                }

                case CustomRPC.FixAnimation:
                {
                    var player = Utils.PlayerById(reader.ReadByte());
                    player.MyPhysics.ResetMoveState();
                    player.Collider.enabled     = true;
                    player.moveable             = true;
                    player.NetTransform.enabled = true;
                    break;
                }

                case CustomRPC.SetButtonBarry:
                    new ButtonBarry(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetCoroner:
                    new Coroner(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetCarnivore:
                    new Carnivore(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.BarryButton:
                    var buttonBarry = Utils.PlayerById(reader.ReadByte());
                    if (AmongUsClient.Instance.AmHost)
                    {
                        MeetingRoomManager.Instance.reporter = buttonBarry;
                        MeetingRoomManager.Instance.target   = null;
                        AmongUsClient.Instance.DisconnectHandlers.AddUnique(MeetingRoomManager.Instance
                                                                            .Cast <IDisconnectHandler>());
                        if (ShipStatus.Instance.CheckTaskCompletion())
                        {
                            return;
                        }

                        DestroyableSingleton <HudManager> .Instance.OpenMeetingRoom(buttonBarry);

                        buttonBarry.RpcStartMeeting(null);
                    }

                    break;

                case CustomRPC.CoronerReveal:
                {
                    PlayerControl player  = Utils.PlayerById(reader.ReadByte());
                    Coroner       coroner = Modifier.GetModifier <Coroner>(player);
                    byte          eatenId = reader.ReadByte();
                    coroner.Reveal(eatenId);
                    break;
                }

                case CustomRPC.CarnivoreEat:
                {
                    PlayerControl player    = Utils.PlayerById(reader.ReadByte());
                    Carnivore     carnivore = Modifier.GetModifier <Carnivore>(player);
                    byte          eatenId   = reader.ReadByte();
                    carnivore.Eat(eatenId);
                    break;
                }

                case CustomRPC.SetUndertaker:
                    new Undertaker(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.Drag:
                {
                    readByte1 = reader.ReadByte();
                    var dienerPlayer = Utils.PlayerById(readByte1);
                    var dienerRole   = Role.GetRole <Undertaker>(dienerPlayer);
                    readByte = reader.ReadByte();
                    var dienerBodies = Object.FindObjectsOfType <DeadBody>();
                    foreach (var body in dienerBodies)
                    {
                        if (body.ParentId == readByte)
                        {
                            dienerRole.CurrentlyDragging = body;
                        }
                    }
                    break;
                }

                case CustomRPC.Drop:
                {
                    byte    undertakerId   = reader.ReadByte();
                    Vector2 deadBodyVector = reader.ReadVector2();
                    var     dienerPlayer2  = Utils.PlayerById(undertakerId);
                    var     dienerRole2    = Role.GetRole <Undertaker>(dienerPlayer2);
                    var     body           = dienerRole2.CurrentlyDragging;
                    dienerRole2.CurrentlyDragging = null;
                    body.TruePosition.Set(deadBodyVector.x, deadBodyVector.y);
                    break;
                }

                case CustomRPC.SetUnderdog:
                    new Underdog(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetTeleporter:
                    new Teleporter(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetConcealer:
                    new Concealer(Utils.PlayerById(reader.ReadByte()));
                    break;

                case CustomRPC.SetPhantom:
                    readByte = reader.ReadByte();
                    SetPhantom.WillBePhantom = readByte == byte.MaxValue ? null : Utils.PlayerById(readByte);
                    break;

                case CustomRPC.PhantomDied:
                    var phantom = SetPhantom.WillBePhantom;
                    Role.RoleDictionary.Remove(phantom.PlayerId);
                    var phantomRole = new Phantom(phantom);
                    phantomRole.RegenTask();
                    phantom.gameObject.layer = LayerMask.NameToLayer("Players");
                    SetPhantom.RemoveTasks(phantom);
                    SetPhantom.AddCollider(phantomRole);
                    PlayerControl.LocalPlayer.MyPhysics.ResetMoveState();
                    System.Console.WriteLine("Become Phantom - Users");
                    break;

                case CustomRPC.CatchPhantom:
                    var phantomPlayer = Utils.PlayerById(reader.ReadByte());
                    Role.GetRole <Phantom>(phantomPlayer).Caught = true;
                    break;

                case CustomRPC.PhantomWin:
                    Role.GetRole <Phantom>(Utils.PlayerById(reader.ReadByte())).CompletedTasks = true;
                    break;

                case CustomRPC.AddMayorVoteBank:
                    Role.GetRole <Mayor>(Utils.PlayerById(reader.ReadByte())).VoteBank += reader.ReadInt32();
                    break;
                }
            }
        public void When_fields_controlled_by_jsonnet_attributes_should_respect_attributes()
        {
            var alice = new Lover {
                Id = "alice"
            };
            var bob = new Lover {
                Id = "bob"
            };
            var cedric = new Lover {
                Id = "cedric"
            };

            //the love triangle
            alice.Loves  = bob;
            bob.Loves    = cedric;
            cedric.Loves = alice;


            var json = JsonConvert.SerializeObject(alice, settings);

            Assert.Equal(@"
{
    ""data"": {
        ""type"": ""lover"",
        ""id"": ""alice"",
        ""relationships"": {
            ""loves"": {
                ""data"": {
                    ""id"": ""bob"",
                    ""type"": ""lover""
                }
            }
        }
    },
    ""included"": [
    {
        ""type"": ""lover"",
        ""id"": ""bob"",
        ""relationships"": {
            ""loves"": {
                ""data"": {
                    ""id"": ""cedric"",
                    ""type"": ""lover""
                }
            }
        }
    },
    {
        ""type"": ""lover"",
        ""id"": ""cedric"",
        ""relationships"": {
            ""loves"": {
                ""data"": {
                    ""id"": ""alice"",
                    ""type"": ""lover""
                }
            }
        }
    }]
}", json, JsonStringEqualityComparer.Instance);
        }
Пример #12
0
 public void RemoveList(Lover _lover)
 {
     m_Lovers.Remove(_lover);
 }
Пример #13
0
 public void AddList(Lover _Lover)
 {
     m_Lovers.Add(_Lover);
 }
Пример #14
0
 public void Update(Lover entity)
 {
     _dbContext.Lovers.Update(entity);
 }
Пример #15
0
 public void Delete(Lover entity)
 {
     _dbContext.Lovers.Remove(entity);
 }
Пример #16
0
 public void Add(Lover entity)
 {
     _dbContext.Lovers.Add(entity);
 }