Example #1
0
    public static string RenderSuccess(this Asset asset, long perspective)
    {
        var result = string.Empty;

        var strength = asset.ActionStrength(perspective);
        var order    = Service.GetOrderOfAssetFromPerspective(perspective, asset.Id);
        var target   = Service.GetAsset(order.TargetId);
        var defense  = target.Defense(perspective);

        if (order.Action.Equals(Order.Actions.Damage.ToString()) || order.Action.Equals(Order.Actions.Infiltrate.ToString()))
        {
            var MoS = strength - defense;

            if (MoS >= target.Value)
            {
                result = string.Format("<span style='color:lime'>exceptional success (MoS = {0})</span>", MoS);
            }
            else if (MoS > 0)
            {
                result = string.Format("<span style='color:green'>success (MoS = {0})</span>", MoS);
            }
            else
            {
                result = string.Format("<span style='color:red'>failure (MoS = {0})</span>", MoS);
            }
        }
        else
        {
            // thwarted by Damage?
            var MoS = strength - target.Value;

            if (MoS > 0)
            {
                result = string.Format("<span style='color:green'>exceptional success (defense +{0})</span>", strength);
            }
            else
            {
                result = string.Format("<span style='color:green'>success (defense +{0})</span>", strength);
            }
        }

        return(result);
    }