Help with a custom mechanic

I'm working on putting a certain custom set named Caeia into Forge, and needed some help coding some new mechanics. The first is Purity, an ability word that checks for two characteristics. First it checks that the player controls a permanent with X color, and second, it checks that the same player doesn't control any permanent with any other color than X. Said in other words, it checks that X is the only color among permanents you control. I've tried to code it in the same way that metalcraft is coded for some cards, but it doesn't works. First I made:
Arathan Inquisition 1 B
Sorcery
Target player discards a card. If black is the only color among permanents you control, that players loses 1 life and you gain 1 life.
Actually, the life drain (Purity) effect doesn't trigger (Don't remember the exact word) only when the Permanents SVar is 0.
The second ability is a Keyword named Prismatic. It says, when this permanent enters the battlefield and at the beggining of you upkeep chose a color. This permanent becomes that color. The mechanic is perfectly coded, but the problem comes with cards that grant Prismatic. I'm able to give both triggers, but I don't know how to code the static ability of SetColor to chosen color.
I would be very thankful to anybody that could help me.
Arathan Inquisition 1 B
Sorcery
Target player discards a card. If black is the only color among permanents you control, that players loses 1 life and you gain 1 life.
- Arathan Inquisition | Open
Actually, the life drain (Purity) effect doesn't trigger (Don't remember the exact word) only when the Permanents SVar is 0.
The second ability is a Keyword named Prismatic. It says, when this permanent enters the battlefield and at the beggining of you upkeep chose a color. This permanent becomes that color. The mechanic is perfectly coded, but the problem comes with cards that grant Prismatic. I'm able to give both triggers, but I don't know how to code the static ability of SetColor to chosen color.
- | Open
I would be very thankful to anybody that could help me.