﻿#pragma strict

public class ArtifactInfluence
{
    private var crown   : Influence;
    private var scepter : Influence;
    private var amulet  : Influence;

    public var artifactMask : int = 0;

    public function ArtifactInfluence()
    {
        crown   = new Influence(0, Artifact.CROWN);
        scepter = new Influence(0, Artifact.SCEPTER);
        amulet  = new Influence(0, Artifact.AMULET);
    }

    public function hasArtifact(artifact : int) : boolean
    {
        return (artifact & artifactMask) == artifact;
    }

    public function getInfluenceFor(artifact : int) : float
    {
        switch (artifact)
        {
        case Artifact.CROWN:
            return crown.getInfluence();
        case Artifact.SCEPTER:
            return scepter.getInfluence();
        case Artifact.AMULET:
            return amulet.getInfluence();
        }

        return 0.0;
    }

    public function setInfluenceFor(artifact : int, amount : float)
    {
        switch (artifact)
        {
        case Artifact.CROWN:
            crown.setInfluence(amount);
            break;
        case Artifact.SCEPTER:
            scepter.setInfluence(amount);
            break;
        case Artifact.AMULET:
            amulet.setInfluence(amount);
            break;
        }
    }

    public function addInfluenceFor(artifact : int, amount : float)
    {
        switch (artifact)
        {
        case Artifact.CROWN:
            crown.setInfluence(crown.getInfluence() + amount);
            break;
        case Artifact.SCEPTER:
            scepter.setInfluence(scepter.getInfluence() + amount);
            break;
        case Artifact.AMULET:
            amulet.setInfluence(amulet.getInfluence() + amount);
            break;
        }
    }

    public function takeInfluenceFor(artifact : int, amount : float)
    {
        switch (artifact)
        {
        case Artifact.CROWN:
            crown.setInfluence(crown.getInfluence() - amount);
            break;
        case Artifact.SCEPTER:
            scepter.setInfluence(scepter.getInfluence() - amount);
            break;
        case Artifact.AMULET:
            amulet.setInfluence(amulet.getInfluence() - amount);
            break;
        }
    }

    public function addInfluenceAll(amount : float)
    {
        crown.setInfluence(crown.getInfluence() + amount);
        scepter.setInfluence(scepter.getInfluence() + amount);
        amulet.setInfluence(amulet.getInfluence() + amount);
    }
}
@@ -2470,10 +2470,265 @@
 );%0A    %7D
+%0A%0A    public function stringify() : String%0A    %7B%0A        return%0A            %22Crown influence: %22 + crown.getInfluence() + %22%5Cn%22%0A          + %22Scepter influence: %22 + scepter.getInfluence() + %22%5Cn%22%0A          + %22Amulet influence: %22 + amulet.getInfluence();%0A    %7D
 %0A%7D

stringify func