Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
Brilliant Ultimatum : Coding opinion needed.
Moderator: CCGHQ Admins
Brilliant Ultimatum : Coding opinion needed.
by NeoAnderson » 04 Sep 2014, 23:00
Hi guys I would ask an opinion about the coding of the card : Brilliant Ultimatum
Here you can find an implementation i just made.
The only thing i had to limit is the AI choose, it seems it isn't able to take reasonable choice when have to separate the cards into 2 piles, so i have make it more simple using a random number to decide how many cards there are into first pile then the second will contain the reamining cards.
Obviously i could make it more complex preparing a chest with scores just to separate the piles...
Here you can find an implementation i just made.
The only thing i had to limit is the AI choose, it seems it isn't able to take reasonable choice when have to separate the cards into 2 piles, so i have make it more simple using a random number to decide how many cards there are into first pile then the second will contain the reamining cards.
Obviously i could make it more complex preparing a chest with scores just to separate the piles...
- Brilliant Ultimatum NEO VER. 1.0 | Open
- Code: Select all
<?xml version="1.0"?>
<CARD_V2 ExportVersion="1">
<FILENAME text="NEO_ALA_159_BRILLIANT_ULTIMATUM_575175143" />
<CARDNAME text="BRILLIANT_ULTIMATUM" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Brilliant Ultimatum]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Ultimatum luminescent]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Ultimátum brillante]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Geistreiches Ultimatum]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Ultimatum Geniale]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[輝く根本原理]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Brilliant Ultimatum]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Блестящий Ультиматум]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Ultimato Brilhante]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[聪智通牒]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[Brilliant Ultimatum]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="575175143" />
<ARTID value="575175143" />
<ARTIST name="Anthony Francisco" />
<CASTING_COST cost="{W}{W}{U}{U}{U}{B}{B}" />
<FLAVOURTEXT>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Revealing the truth only deepened Tezzeret’s curiosity for the secrets still buried.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[La révélation de la vérité ne fit qu’attiser la curiosité de Tezzeret pour les secrets encore ensevelis.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Encontrar la verdad sólo profundizó la curiosidad de Tezzeret por los secretos todavía ocultos.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Das Aufdecken der Wahrheit verstärkte nur Tezzerets Neugier auf noch verborgene Geheimnisse.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Rivelare la verità servì solo ad aumentare la curiosità di Tezzeret per i segreti ancora sepolti.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[真実を解き明かした結果、テゼレットの埋もれた秘密に対する好奇心は深まるばかりだった。]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Revealing the truth only deepened Tezzeret’s curiosity for the secrets still buried.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Правда лишь подогрела интерес Теззерета к все еще не раскрытым тайнам.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Desvendar a verdade apenas aumentou a curiosidade de Tezzeret pelos segredos ainda enterrados.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[泰兹瑞不以揭开真相为满足,其好奇心永远想追寻尚未揭晓的秘密。]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[Revealing the truth only deepened Tezzeret’s curiosity for the secrets still buried.]]></LOCALISED_TEXT>
</FLAVOURTEXT>
<TYPE metaname="Sorcery" />
<EXPANSION value="ALA" />
<RARITY metaname="R" />
<SPELL_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Exile the top five cards of your library. An opponent separates those cards into two piles. You may play any number of cards from one of those piles without paying their mana costs.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Retirez de la partie les cinq cartes du dessus de votre bibliothèque. Un adversaire sépare ces cartes en deux tas. Vous pouvez jouer n’importe quel nombre de cartes de l’un de ces tas sans payer leurs coûts de mana.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Remueve del juego las primeras cinco cartas de tu biblioteca. Un oponente separa esas cartas en dos montones. Puedes jugar cualquier cantidad de cartas de uno de esos montones sin pagar sus costes de maná.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Entferne die obersten fünf Karten deiner Bibliothek ganz aus dem Spiel. Ein Gegner teilt diese Karten auf zwei Stapel auf. Du kannst von einem dieser Stapel eine beliebige Anzahl von Karten spielen, ohne ihre Manakosten zu bezahlen.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Rimuovi dal gioco le prime cinque carte del tuo grimorio. Un avversario separa quelle carte in due pile. Puoi giocare un qualsiasi numero di carte da una di quelle pile senza pagare i loro costi di mana.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたのライブラリーの一番上から5枚のカードをゲームから取り除く。 いずれかの対戦相手は、それらのカードを2つの束に分ける。 あなたはそれらの束のうち1つにある各カードを望む枚数だけ、それのマナ・コストを支払うことなくプレイしてもよい。]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Exile the top five cards of your library. An opponent separates those cards into two piles. You may play any number of cards from one of those piles without paying their mana costs.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Удалите из игры пять верхних карт вашей библиотеки. Оппонент делит те карты на две стопки. Вы можете разыграть любое количество карт из одной из тех стопок без уплаты их мана-стоимости.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Remova do jogo os cinco cards do topo de seu grimório. Um oponente separa esses cards em duas pilhas. Você pode jogar qualquer quantidade de cards de uma dessas pilhas sem pagar seus custos de mana.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-CN"><![CDATA[将你牌库顶的五张牌移出对战。 由任一对手将它们分成两堆。 你可以使用在其中一堆的任意数量牌,且不需支付其法术力费用。]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="zh-HK"><![CDATA[Exile the top five cards of your library. An opponent separates those cards into two piles. You may play any number of cards from one of those piles without paying their mana costs.]]></LOCALISED_TEXT>
<RESOLUTION_TIME_ACTION>
local queryDC = EffectDC():Make_Chest(1)
local player = EffectController()
for i=0,(5-1) do
local card = player:Library_GetNth(i)
if card ~= nil then
queryDC:Set_CardPtr(i, card)
queryDC:Protect_CardPtr(i)
card:Exile()
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local filter = ClearFilter()
filter:SetFilterType(FILTER_TYPE_PLAYERS)
filter:Add( FE_TEAM, OP_NOT, EffectController():GetTeam() )
EffectController():ChooseItem( "CARD_QUERY_CHOOSE_OPPONENT", EffectDC():Make_Targets(4) )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local queryDC = EffectDC():Get_Chest(1)
local player = EffectDC():Get_Targets(4) and EffectDC():Get_Targets(4):Get_PlayerPtr(0)
if player:IsAI() then
local RandIndex = math.random(0, 5)
player:SetItemCount(RandIndex)
for i = 0, (RandIndex - 1) do
player:SetItemPrompt(i, "CARD_QUERY_PILE1" )
end
player:ChooseItemsFromDC( queryDC, EffectDC():Make_Targets(0))
else
player:SetItemCount(5)
for i = 0, (5 - 1) do
player:SetItemPrompt(i, "CARD_QUERY_PILE1" )
end
player:ChooseItemsFromDC( queryDC, EffectDC():Make_Targets(0), QUERY_FLAG_UP_TO )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local queryDC = EffectDC():Get_Chest(1)
-- local answerDC = EffectDC():Get_Targets(0)
local diff = 0
if EffectDC():Get_Targets(0) ~= nil then
diff = EffectDC():Get_Targets(0):Count()
end
local player = EffectDC():Get_Targets(4) and EffectDC():Get_Targets(4):Get_PlayerPtr(0)
if (player ~= nil) and (queryDC ~= nil) then
for i=0, queryDC:Count()-1 do
local card = queryDC:Get_CardPtr(i)
local was_selected = false
for j=0, diff-1 do
local cardB = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(j)
if cardB ~= nil then
if card == cardB then
was_selected = true
break
end
end
end
if was_selected == true then
queryDC:QueryUnselect_CardPtr(i)
end
end
if diff < 5 then
player:SetItemCount(5-diff)
for i = 0, (4-diff) do
player:SetItemPrompt(i, "CARD_QUERY_PILE2" )
end
player:ChooseItemsFromDC( queryDC, EffectDC():Make_Targets(3) )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local count = 0
local countB = 0
if EffectDC():Get_Targets(0) ~= nil then
count = EffectDC():Get_Targets(0):Count()
end
if EffectDC():Get_Targets(3) ~= nil then
countB = EffectDC():Get_Targets(3):Count()
end
local player = EffectController()
if player ~= nil then
if player:IsAI() then
local Qscore = 0
for i=0,count-1 do
local card = EffectDC():Get_Targets(0):Get_CardPtr(i)
if card ~= nil then
local score = card:CalcPotentialScore()
Qscore = Qscore + score
end
end
local Ascore = 0
for i=0,countB-1 do
local cardB = EffectDC():Get_Targets(3):Get_CardPtr(i)
if cardB ~= nil then
local score = cardB:CalcPotentialScore()
Ascore = Ascore + score
end
end
if Qscore >= Ascore then
EffectDC():Set_Int(200, 2)
else
EffectDC():Set_Int(200, 1)
end
EffectDC():Set_Int(300, 2)
else
EffectDC():Set_Int(300, 1)
-- scrivere codice per giocatore non CPU
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local player = EffectController()
if player ~= nil then
if EffectDC():Get_Int(300) == 1 then
local count = 0
local countB = 0
if EffectDC():Get_Targets(0) ~= nil then
count = EffectDC():Get_Targets(0):Count()
end
if EffectDC():Get_Targets(3) ~= nil then
countB = EffectDC():Get_Targets(3):Count()
end
local QueryStringA =""
for i=0,count-1 do
local card = EffectDC():Get_Targets(0):Get_CardPtr(i)
if card ~= nil then
local name = card:GetCardName()
QueryStringA = name.." - "..QueryStringA
end
end
local QueryStringB =""
for i=0, countB-1 do
local card = EffectDC():Get_Targets(3):Get_CardPtr(i)
if card ~= nil then
local name = card:GetCardName()
QueryStringB = name.." - "..QueryStringB
end
end
player:BeginNewMultipleChoice()
player:AddMultipleChoiceAnswer( QueryStringA )
player:AddMultipleChoiceAnswer( QueryStringB )
player:AskMultipleChoiceQuestion( "CARD_QUERY_BRILLIANT_ULTIMATUM" )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local player = EffectController()
if player ~= nil then
if EffectDC():Get_Int(300) == 1 then
local result = player:GetMultipleChoiceResult()
if result == 0 then
EffectDC():Set_Int(200, 2)
elseif result == 1 then
EffectDC():Set_Int(200, 1)
end
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local queryDC = EffectDC():Make_Chest(6)
local k = 0
if EffectDC():Get_Int(200) == 2 then
k = 0
else
k = 3
end
local player = EffectController()
if player ~= nil then
local count = EffectDC():Get_Targets(k):Count()
for i=0, (count-1) do
local card = EffectDC():Get_Targets(k):Get_CardPtr(i)
if card ~= nil then
queryDC:Set_CardPtr(i, card)
queryDC:Protect_CardPtr(i)
end
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local queryDC = EffectDC():Get_Chest(6)
if queryDC ~= nil then
local count = queryDC:Count()
local player = EffectController()
if (player ~= nil) then
for i=0, (count-1) do
local card = queryDC:Get_CardPtr(i)
if card ~= nil then
card:GrantPseudoFlash()
if EffectController():CanCastSpellForFree(card) == false then
queryDC:QueryUnselect_CardPtr(i)
count = count - 1
end
end
end
player:SetItemCount(count)
for i = 0, (count - 1) do
player:SetItemPrompt(i, "CARD_QUERY_CARDTOPLAY" )
end
player:ChooseItemsFromDC( queryDC, EffectDC():Make_Targets(5), QUERY_FLAG_UP_TO )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local player = EffectController()
if player ~= nil then
local count = EffectDC():Get_Targets(5):Count()
for i=0, (count-1) do
local card = EffectDC():Get_Targets(5):Get_CardPtr(i)
if card ~= nil then
card:GrantPseudoFlash()
if EffectController():CanCastSpellForFree(card) then
EffectController():CastSpellForFree(card)
end
end
end
end
</RESOLUTION_TIME_ACTION>
</SPELL_ABILITY>
</CARD_V2>
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 32 guests