public static IEnumerable <MapLocation> AccessibleMapLocations( AccessRequirement currentAccess, MapChange currentMapChanges, Dictionary <MapLocation, Tuple <List <MapChange>, AccessRequirement> > fullLocationRequirements) { return(fullLocationRequirements.Where(x => x.Value.Item1.Any(y => currentMapChanges.HasFlag(y) && currentAccess.HasFlag(x.Value.Item2))).Select(x => x.Key)); }
private void BuildInitialRequirements(IVictoryConditionFlags victoryConditions) { airShipLocationAccessible = false; requirements = AccessRequirement.None; if ((bool)victoryConditions.FreeLute) { requirements |= AccessRequirement.Lute; } changes = MapChange.None; if (victoryConditions.IsBridgeFree ?? false) { changes |= MapChange.Bridge; } if (victoryConditions.IsShipFree ?? false) { changes |= MapChange.Ship; SetShipDock(255); } if (victoryConditions.IsAirshipFree ?? false) { changes |= MapChange.Airship; airShipLocationAccessible = true; } if (victoryConditions.IsCanalFree ?? false) { changes |= MapChange.Canal; } if (victoryConditions.IsCanoeFree ?? false) { changes |= MapChange.Canoe; } }
public MapObject(ObjectId objectId, MapLocation mapLocation, Item item, AccessRequirement accessRequirement = AccessRequirement.None, ObjectId requiredGameEventFlag = ObjectId.None, Item requiredItemTrade = Item.None, MapLocation requiredSecondLocation = MapLocation.StartingLocation, bool useVanillaRoutineAddress = true) : base(_mapObjectTalkDataAddress + _giftItemIndex + _mapObjectTalkDataSize * (byte)objectId, Enum.GetName(typeof(ObjectId), objectId), mapLocation, item, accessRequirement) { ObjectId = objectId; _objectRoutineAddress = (byte)objectId * _mapObjTalkJumpTblDataSize + _mapObjTalkJumpTblAddress; _requiredGameEventFlag = requiredGameEventFlag; _requiredItemTrade = requiredItemTrade; _useVanillaRoutineAddress = useVanillaRoutineAddress; SecondLocation = requiredSecondLocation; if (_requiredGameEventFlag != ObjectId.None && _requiredItemTrade != Item.None) { throw new InvalidOperationException( $"Attempted to Put invalid npc item placement: \n{SpoilerText}"); } }
public SCRequirementsSet(AccessRequirement accessRequirement) { var requirement = SCRequirements.None; if (accessRequirement.HasFlag(AccessRequirement.Key)) { requirement |= SCRequirements.Key; } if (accessRequirement.HasFlag(AccessRequirement.Rod)) { requirement |= SCRequirements.Rod; } if (accessRequirement.HasFlag(AccessRequirement.Oxyale)) { requirement |= SCRequirements.Oxyale; } if (accessRequirement.HasFlag(AccessRequirement.Cube)) { requirement |= SCRequirements.Cube; } if (accessRequirement.HasFlag(AccessRequirement.Bottle)) { requirement |= SCRequirements.Bottle; } if (accessRequirement.HasFlag(AccessRequirement.Lute)) { requirement |= SCRequirements.Lute; } if (accessRequirement.HasFlag(AccessRequirement.Crown)) { requirement |= SCRequirements.Crown; } if (accessRequirement.HasFlag(AccessRequirement.Crystal)) { requirement |= SCRequirements.Crystal; } if (accessRequirement.HasFlag(AccessRequirement.Herb)) { requirement |= SCRequirements.Herb; } if (accessRequirement.HasFlag(AccessRequirement.Tnt)) { requirement |= SCRequirements.Tnt; } if (accessRequirement.HasFlag(AccessRequirement.Adamant)) { requirement |= SCRequirements.Adamant; } if (accessRequirement.HasFlag(AccessRequirement.Slab)) { requirement |= SCRequirements.Slab; } if (accessRequirement.HasFlag(AccessRequirement.Ruby)) { requirement |= SCRequirements.Ruby; } Add(requirement); }
public StaticItemLocation(string name, MapLocation mapLocation, Item item, AccessRequirement accessRequirement = AccessRequirement.None) : base(address++, name, mapLocation, item, accessRequirement) { if (address >= int.MaxValue) { address = 0x80000; } }
protected RewardSourceBase(int address, string name, MapLocation mapLocation, Item item, AccessRequirement accessRequirement = AccessRequirement.None, bool isUnused = false) { Address = address; Name = name; Item = item; MapLocation = mapLocation; AccessRequirement = accessRequirement; IsUnused = isUnused; }
public void CanHandleDfdsAccessRequirements() { //Arrange var fakeRequirements = new AccessRequirement[] { new ExecuteAccessRequirement(), new ReadAccessRequirement(), new WriteAccessRequirement() }; var fakeIdentity = new ClaimsIdentity(new[] { new Claim("dfds.access", "dfds.all.execute"), new Claim("dfds.access", "dfds.all.read"), new Claim("dfds.access", "dfds.all.write") }); var fakePrincipal = new ClaimsPrincipal(fakeIdentity); var fakeAuthorizationHandlerContext = new AuthorizationHandlerContext(fakeRequirements, fakePrincipal, null); var sut = new AccessRequirementHandler(); //Act var task = sut.HandleAsync(fakeAuthorizationHandlerContext); //Assert Assert.True(task.IsCompletedSuccessfully); Assert.True(fakeAuthorizationHandlerContext.HasSucceeded); }
private void ProcessOrb(SCPointOfInterest poi) { switch (poi.ItemId) { case Item.EarthOrb: requirements |= AccessRequirement.EarthOrb; break; case Item.FireOrb: requirements |= AccessRequirement.FireOrb; break; case Item.WaterOrb: requirements |= AccessRequirement.WaterOrb; break; case Item.AirOrb: requirements |= AccessRequirement.AirOrb; break; } poi.Done = true; }
public bool IsAccessible(AccessRequirement req, MapChange chg) { SCBitFlags v2req = SCBitFlags.None; if (req.HasFlag(AccessRequirement.Key)) { v2req |= SCBitFlags.Key; } if (req.HasFlag(AccessRequirement.Rod)) { v2req |= SCBitFlags.Rod; } if (req.HasFlag(AccessRequirement.Oxyale)) { v2req |= SCBitFlags.Oxyale; } if (req.HasFlag(AccessRequirement.Cube)) { v2req |= SCBitFlags.Cube; } if (req.HasFlag(AccessRequirement.Lute)) { v2req |= SCBitFlags.Lute; } if (req.HasFlag(AccessRequirement.Crown)) { v2req |= SCBitFlags.Crown; } if (req.HasFlag(AccessRequirement.Ruby)) { v2req |= SCBitFlags.Ruby; } if (req.HasFlag(AccessRequirement.BlackOrb)) { v2req |= SCBitFlags.Orbs; } if (req.HasFlag(AccessRequirement.Tnt)) { v2req |= SCBitFlags.Tnt; } if (chg.HasFlag(MapChange.Chime)) { v2req |= SCBitFlags.Chime; } if (chg.HasFlag(MapChange.Canoe)) { v2req |= SCBitFlags.Canoe; } if (chg.HasFlag(MapChange.Airship)) { v2req |= SCBitFlags.Floater; } foreach (var flag in this) { if (v2req.IsSupersetOf(flag)) { return(true); } } return(false); }
private void ProcessItem(Item item, byte dungeonIndex) { switch (item) { case Item.Lute: requirements |= AccessRequirement.Lute; break; case Item.Crown: requirements |= AccessRequirement.Crown; break; case Item.Crystal: requirements |= AccessRequirement.Crystal; break; case Item.Herb: requirements |= AccessRequirement.Herb; break; case Item.Key: requirements |= AccessRequirement.Key; break; case Item.Tnt: requirements |= AccessRequirement.Tnt; break; case Item.Adamant: requirements |= AccessRequirement.Adamant; break; case Item.Slab: requirements |= AccessRequirement.Slab; break; case Item.Ruby: requirements |= AccessRequirement.Ruby; changes |= MapChange.TitanFed; break; case Item.Rod: requirements |= AccessRequirement.Rod; break; case Item.Floater: changes |= MapChange.Airship; break; case Item.Chime: changes |= MapChange.Chime; break; case Item.Cube: requirements |= AccessRequirement.Cube; break; case Item.Bottle: requirements |= AccessRequirement.Bottle; break; case Item.Oxyale: requirements |= AccessRequirement.Oxyale; break; case Item.Ship: changes |= MapChange.Ship; SetShipDock(dungeonIndex); break; case Item.Bridge: changes |= MapChange.Bridge; break; case Item.Canal: changes |= MapChange.Canal; break; case Item.Canoe: changes |= MapChange.Canoe; break; } }
public bool IsRewardSourceAccessible(IRewardSource source, AccessRequirement currentAccess, List <MapLocation> locations) { //if (currentAccess != requirements) throw new InvalidOperationException("no can do"); return(rewardSources.Contains(source)); }
public List <MapLocation> AccessibleMapLocations(AccessRequirement currentAccess, MapChange currentMapChanges, Dictionary <MapLocation, Tuple <List <MapChange>, AccessRequirement> > fullLocationRequirements) { throw new NotSupportedException("not needed?"); }
public bool IsRewardSourceAccessible(IRewardSource source, AccessRequirement currentAccess, List <MapLocation> locations) { return(locations.Contains(source.MapLocation) && currentAccess.HasFlag(source.AccessRequirement) && locations.Contains((source as MapObject)?.SecondLocation ?? MapLocation.StartingLocation)); }
public TreasureChest(IRewardSource copyFromRewardSource, Item item, AccessRequirement access) : base(copyFromRewardSource, item) { AccessRequirement = access; }
public TreasureChest(int address, string name, MapLocation mapLocation, Item item, AccessRequirement accessRequirement = AccessRequirement.None, bool isUnused = false) : base(address, name, mapLocation, item, accessRequirement, isUnused) { }