protected override void doActivate(Targetable target) { EdgeData edge = (EdgeData)target; PlayerData currentPlayer = turnController.CurrentPlayer; if (edge.getOwner() == currentPlayer) { return; } float randomValue = 1.0f; while (randomValue == 1.0f) { randomValue = UnityEngine.Random.value; } if (randomValue < getSuccessProbability(target)) { //remove all ownership of the edge (and make it unusable) edge.direction = EdgeData.EdgeDirection.Unusable; //set it back to neutral in a few turns System.Action directionResetter = null; int numTurnsRemaining = NumTurnsTargetDeactivated; directionResetter = () => { if (turnController.CurrentPlayer == currentPlayer) { numTurnsRemaining--; } if (numTurnsRemaining == 0) { edge.direction = EdgeData.EdgeDirection.Neutral; turnController.OnTurnEnd -= directionResetter; } }; turnController.OnTurnEnd += directionResetter; //TODO possibly reveal the user of the edge, if any? } }
public override bool viewAsOwned(Player.VisibilityController.Visibility visibility) { bool isPrivate = visibility == VisibilityController.Visibility.Private; return(isPrivate && Edge.getOwner() == turnController.CurrentPlayer); }