It is currently 01 Sep 2025, 06:21
   
Text Size

Will of the Council

Moderator: CCGHQ Admins

Will of the Council

Postby volrathxp » 08 Aug 2014, 23:17

I know that we can do multiple choice questions, but is something like Will of the Council capable under Dotp 2014?

I thought about adding some of the more fun Council cards, but not really sure if the voting thing is possible. Especially something like Custodi Squire (voting for individual cards in a graveyard, etc).
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby sweetLu » 09 Aug 2014, 00:08

Sure. It wouldn't be a multiple choice question though. It would be like any other "choose a card" card. Just loop through all the players with the appropriate "choose a card" function and then simply evaluate the results.

For an example look at a card like Distress. It should do something like set up a filter for the target players hand then use ChooseItems() to get the chosen card. For will of the council you would have the filter be for permanents that aren't controlled by the casting player, then you'd have all players choose a card according to that filter.
sweetLu
 
Posts: 181
Joined: 16 Jul 2014, 01:24
Has thanked: 21 times
Been thanked: 22 times

Re: Will of the Council

Postby volrathxp » 09 Aug 2014, 00:21

sweetLu wrote:Sure. It wouldn't be a multiple choice question though. It would be like any other "choose a card" card. Just loop through all the players with the appropriate "choose a card" function and then simply evaluate the results.

For an example look at a card like Distress. It should do something like set up a filter for the target players hand then use ChooseItems() to get the chosen card. For will of the council you would have the filter be for permanents that aren't controlled by the casting player, then you'd have all players choose a card according to that filter.
Well, most Will of the Council cards have the players selecting a thing, not a card (like... Tyrant's Choice for example, has the players voting for "death" or "torture").

Custodi Squire is the only one that really has a card selection.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby sweetLu » 09 Aug 2014, 00:47

Oh sorry I should have looked up some more. I've only seen Council's Judgment so I got confused.

You can set the multiple choice question up any way you want after you define the localized text files. You could do:

Question: Vote death or torture.
A1: Death - each opponent sacrifices a creature.
A2: Torture - each opponent losses 4 life.
sweetLu
 
Posts: 181
Joined: 16 Jul 2014, 01:24
Has thanked: 21 times
Been thanked: 22 times

Re: Will of the Council

Postby volrathxp » 09 Aug 2014, 01:13

sweetLu wrote:Oh sorry I should have looked up some more. I've only seen Council's Judgment so I got confused.

You can set the multiple choice question up any way you want after you define the localized text files. You could do:

Question: Vote death or torture.
A1: Death - each opponent sacrifices a creature.
A2: Torture - each opponent losses 4 life.
That's kind of what I was thinking. Hmmph. I'll have to look at it some more when I have time. I don't have a whole lot of experience in multi-choice questions yet, so I'll have to see if I can't find a good card to work off of.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby RiiakShiNal » 09 Aug 2014, 01:50

It would even be possible to make Brago's Representative. You use a Player chest and do appropriate clearing (like I do for custom characteristics) then as a static ability you have Brago's Representative increment a register, for the "Vote" cards you have it check that register to see how many votes each player should get and give them the appropriate number of choices at the appropriate time. For example on a repeating action instead of using the number of repetitions to determine player number, you use it to determine a register index that gets the proper player pointer to ask. For example Player 1 has no representatives, Player 2 has two representatives, and player 3 has one representative the vote registers might look like this:
0 - Player 1
1 - Player 2
2 - Player 2
3 - Player 2
4 - Player 3
5 - Player 3
So the repeating action would repeat 7 or 12 times (depending on how implemented) to ask, get, and record all the votes.

The next action could tally them and do the appropriate action or store them so the action can be carried out later.
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Will of the Council

Postby volrathxp » 11 Aug 2014, 01:25

So I'm trying to get a good basis for this, wanting to know if I'm going into the right direction here, or I'm making this too hard on myself.

Working on setting up Bite of the Black Rose.

I don't have much experience with multi-choice questions and especially with effects that work off each player, so my brain is trying to wrap around it. Also, trying to understand how I tally the votes. I'm sure I can store those into Ints, but not sure how...

Code Snippet - Bite of the Black Rose | Open
Code: Select all
<RESOLUTION_TIME_ACTION>
    for i=0,(MTG():GetNumberOfPlayers()-1) do
       local player = MTG():GetNthPlayer(i)
       if player ~= nil then
         if player == EffectController() then
             EffectDC():Set_Int(5, i)
         end
       end
    end
    </RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
    local n = MTG():GetActionRepCount()
    local num_players = MTG():GetNumberOfPlayers()
    local m = EffectDC():Get_Int(5)
    local playerindex = ( n/2 + m ) % num_players
    local parity = n % 2
    local player = MTG():GetNthPlayer(playerindex)
    local sickness = 0
    local psychosis = 0

    if player ~= nil and n &lt; num_players*2 then

   if parity == 0 then

      player:AddMultipleChoiceAnswer( "CARD_QUERY_VOTE_SICKNESS" )
      player:AddMultipleChoiceAnswer( "CARD_QUERY_VOTE_PSYCHOSIS" )
      player:AskMultipleChoiceQuestion( "CARD_QUERY_BLACK_ROSE_QUESTION")

   else

      local result = player:GetMultipleChoiceResult()

      if result == 0 then

         sickness = sickness + 1

      else

         psychosis = psychosis + 1

      end

      if sickness &gt; 0 or psychosis &gt; 0 then

         EffectDC():Set_Int(playerindex, EffectDC():Get_Int(playerindex) + result)
                EffectDC():Set_Int(6, 0)

      else

         EffectDC():Int_Inc(6)

      end

      if EffectDC():Get_Int(6) == num_players then

              return false

             end

      return true

   end

       return false

    end

</RESOLUTION_TIME_ACTION>
Edit: Also I haven't added the RTA yet for actually performing the actions, trying to make sure I have the voting portion down.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby sweetLu » 11 Aug 2014, 01:50

That wouldn't work because each iteration you are resetting the sickness and psychosis vote back to 0. You'll have to save the vote count in a data chest. Try something like:

| Open
Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
local n = MTG():GetActionRepCount()
local parity = n%2
local index = n/2
if index &lt; MTG():GetNumberOfStartingPlayers() then
   local player = MTG():GetNthStartingPlayer(index)
    if player ~= nil then
       if parity == 0 then
          player:BeginNewMultipleChoice()
          player:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_SICKNESS")
          player:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_PSYCHOSIS")
          player:AskMultipleChoiceQuestion( "CARD_QUERY_BLACK_ROSE_QUESTION", EffectSource() )
       else
         -- The sickness vote should be stored in EffectDC():Get_Int(0)
         -- The psychosis vote should be stored in EffectDC():Get_Int(1)
          EffectDC():Int_Inc( player:GetMultipleChoiceResult() )
       end
    end
    return true
end
return false
</RESOLUTION_TIME_ACTION>
Edit - Of course this version doesn't account for Brago's Representative as Riiak pointed out but just getting a base version down first should be a good start.
sweetLu
 
Posts: 181
Joined: 16 Jul 2014, 01:24
Has thanked: 21 times
Been thanked: 22 times

Re: Will of the Council

Postby volrathxp » 11 Aug 2014, 02:41

Right. I'm not totally worried about Brago's Representative at this point in time. I kind of figured that was where I was going wrong I just couldn't see where to go with it. I will give that a shot. Thanks!
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby RiiakShiNal » 11 Aug 2014, 10:58

To ask the questions and account for Brago's Representative you would do something along these lines (VOTE_MODIFIER would need to be defined as an unused register to hold the vote modifications, or 0 if no modifications):
Code | Open
Code: Select all
<RESOLUTION_TIME_ACTION>
  -- Make a chest for the player pointers
  local dcPlayers = EffectDC():Make_Chest(1)
  local nPlayers = MTG():GetNumberOfPlayers()
  local nVoteIndex = 0
  -- Loop through all players in order
  for nPlayer = 0, nPlayers-1 do
    local oPlayer = MTG():GetNthPlayer(nPlayer)
    -- Get additional votes (if any)
    local nVotes = oPlayer:PlayerDataChest():Int_Get( VOTE_MODIFIER )
    -- Loop through all votes (to setup voting queue).
    for nVote = 0, nVotes do
      -- Store the player that gets this vote.
      dcPlayers:Set_PlayerPtr(nVoteIndex, oPlayer)
      -- Increment vote index so we don't overwrite any.
      nVoteIndex = nVoteIndex + 1
    end
  end
  -- We have now cycled through all players and setup when
  --  they are going to vote and how many votes they get so
  --  now we need to store how many votes we need to conduct.
  EffectDC():Int_Set(0, nVoteIndex)
  -- Make our voting chest (we don't need the pointer now just need to create it)
  EffectDC():Make_Chest(2)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
  local n = MTG():GetActionRepCount()
  local nNumVotes = EffectDC():Int_Get(0)
  local dcPlayers = EffectDC():Get_Chest(1)
  local dcVotes = EffectDC():Get_Chest(2)
  -- If this is not the first rep then we need to record a vote
  if (n &gt; 0) then
    local nVoteIndex = n - 1
    local oVotePlayer = dcPlayers:Get_PlayerPtr(nVoteIndex)
    dcVotes:Int_Set(nVoteIndex, oVotePlayer:GetMultipleChoiceResult())
  end
  -- Now we check to see if we should continue.
  if (n &gt;= nNumVotes) then
    -- Nope, we already recorded our last vote so end.
    return false
  end
  -- If we got to here then we need to ask a player a question.
  local oPlayer = dcPlayers:Get_PlayerPtr(n)
  oPlayer:BeginNewMultipleChoice()
  oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_SICKNESS")
  oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_PSYCHOSIS")
  oPlayer:AskMultipleChoiceQuestion("CARD_QUERY_BLACK_ROSE_QUESTION", EffectSourceLKI())
  -- We want to continue this repeating action.
  return true
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
  -- Count up the votes
  local nNumVotes = EffectDC():Int_Get(0)
  local dcVotes = EffectDC():Get_Chest(2)
  local nSickness = 0
  local nPsychosis = 0
  for nVote = 0, nNumVotes-1 do
    -- Check which option this is a vote for.
    if (dcVotes:Int_Get(nVote) == 1) then
      nPsychosis = nPsychosis + 1
    else
      nSickness = nSickness + 1
    end
  end
  -- At this point the votes are tallied and can either be stored or used.
  EffectDC():Int_Set(3, nSickness)
  EffectDC():Int_Set(4, nPsychosis)
</RESOLUTION_TIME_ACTION>
Note that I have not added any checks for nil since EffectSourceLKI() should never be nil and there should be no change in the status of the players between our RESOLUTION_TIME_ACTIONs so nil checks should be unnecessary here. If, however, you start getting SCRIPT_LOG errors about referencing a nil value you can put in nil checks and it shouldn't really complicate things much.

This should also be able to handle things like getting card pointers or other things just by changing how the votes are tallied a bit.
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Will of the Council

Postby volrathxp » 11 Aug 2014, 11:28

RiiakShiNal wrote:To ask the questions and account for Brago's Representative you would do something along these lines (VOTE_MODIFIER would need to be defined as an unused register to hold the vote modifications, or 0 if no modifications):
Code | Open
Code: Select all
<RESOLUTION_TIME_ACTION>
  -- Make a chest for the player pointers
  local dcPlayers = EffectDC():Make_Chest(1)
  local nPlayers = MTG():GetNumberOfPlayers()
  local nVoteIndex = 0
  -- Loop through all players in order
  for nPlayer = 0, nPlayers-1 do
    local oPlayer = MTG():GetNthPlayer(nPlayer)
    -- Get additional votes (if any)
    local nVotes = oPlayer:PlayerDataChest():Int_Get( VOTE_MODIFIER )
    -- Loop through all votes (to setup voting queue).
    for nVote = 0, nVotes do
      -- Store the player that gets this vote.
      dcPlayers:Set_PlayerPtr(nVoteIndex, oPlayer)
      -- Increment vote index so we don't overwrite any.
      nVoteIndex = nVoteIndex + 1
    end
  end
  -- We have now cycled through all players and setup when
  --  they are going to vote and how many votes they get so
  --  now we need to store how many votes we need to conduct.
  EffectDC():Int_Set(0, nVoteIndex)
  -- Make our voting chest (we don't need the pointer now just need to create it)
  EffectDC():Make_Chest(2)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
  local n = MTG():GetActionRepCount()
  local nNumVotes = EffectDC():Int_Get(0)
  local dcPlayers = EffectDC():Get_Chest(1)
  local dcVotes = EffectDC():Get_Chest(2)
  -- If this is not the first rep then we need to record a vote
  if (n &gt; 0) then
    local nVoteIndex = n - 1
    local oVotePlayer = dcPlayers:Get_PlayerPtr(nVoteIndex)
    dcVotes:Int_Set(nVoteIndex, oVotePlayer:GetMultipleChoiceResult())
  end
  -- Now we check to see if we should continue.
  if (n &gt;= nNumVotes) then
    -- Nope, we already recorded our last vote so end.
    return false
  end
  -- If we got to here then we need to ask a player a question.
  local oPlayer = dcPlayers:Get_PlayerPtr(n)
  oPlayer:BeginNewMultipleChoice()
  oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_SICKNESS")
  oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_PSYCHOSIS")
  oPlayer:AskMultipleChoiceQuestion("CARD_QUERY_BLACK_ROSE_QUESTION", EffectSourceLKI())
  -- We want to continue this repeating action.
  return true
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
  -- Count up the votes
  local nNumVotes = EffectDC():Int_Get(0)
  local dcVotes = EffectDC():Get_Chest(2)
  local nSickness = 0
  local nPsychosis = 0
  for nVote = 0, nNumVotes-1 do
    -- Check which option this is a vote for.
    if (dcVotes:Int_Get(nVote) == 1) then
      nPsychosis = nPsychosis + 1
    else
      nSickness = nSickness + 1
    end
  end
  -- At this point the votes are tallied and can either be stored or used.
  EffectDC():Int_Set(3, nSickness)
  EffectDC():Int_Set(4, nPsychosis)
</RESOLUTION_TIME_ACTION>
Note that I have not added any checks for nil since EffectSourceLKI() should never be nil and there should be no change in the status of the players between our RESOLUTION_TIME_ACTIONs so nil checks should be unnecessary here. If, however, you start getting SCRIPT_LOG errors about referencing a nil value you can put in nil checks and it shouldn't really complicate things much.

This should also be able to handle things like getting card pointers or other things just by changing how the votes are tallied a bit.
Where would I set the VOTE_MODIFIER at? Would that be in one of the .LOL files?
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby RiiakShiNal » 11 Aug 2014, 11:31

Yes, that would be set in a LOL file and the value assigned to that register would be increased by Brago's Representative and regularly cleared by an invisible token manager (so that it doesn't get artificially inflated by exchanging control of Brago's representative or flickering).

Remember it should be a register that is not used by anyone else or it could cause problems either with other cards or with voting.
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Will of the Council

Postby volrathxp » 12 Aug 2014, 00:02

RiiakShiNal wrote:Yes, that would be set in a LOL file and the value assigned to that register would be increased by Brago's Representative and regularly cleared by an invisible token manager (so that it doesn't get artificially inflated by exchanging control of Brago's representative or flickering).

Remember it should be a register that is not used by anyone else or it could cause problems either with other cards or with voting.
I've looked at a few of the constant files in other DLC's, but I can't seem to really figure this out. How do I know that I've picked a number or register that isn't used by anyone else?

I'm also a little fuzzy on the token manager.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Will of the Council

Postby RiiakShiNal » 12 Aug 2014, 00:25

volrathxp wrote:I've looked at a few of the constant files in other DLC's, but I can't seem to really figure this out. How do I know that I've picked a number or register that isn't used by anyone else?
Constants are easy. You simply pick a name (usually all caps to indicate it's not going to change) and then equate it to something. As for picking the value usually you pick a pretty high value (but still less than 2 billion) usually starting with your reserved Id Block number and usually you're okay. For example since my Id Block is 8192 my constants for registers all start with 8192 (then I usually add a sequential number afterwards). Like my value for the target chest for Defending Player is 81920011. Most modders use low numbers for registers when creating cards (0, 1, 2, etc...), but for shared registers like the Duel Data Chest and the Player Data Chest use high numbers that are unlikely to be used by other people.

volrathxp wrote:I'm also a little fuzzy on the token manager.
Invisible managers get to be tricky, take a look at my custom Characteristics code for more information on how your manager would need to work. Your manager would not work quite the same as mine, but would need to be similar (you would be incrementing and clearing a value on the player instead of on a card). The good news is you would only need to worry about the manager for Brago's Representative and similar cards. If the card is only reading from the value and not modifying it then it doesn't have to worry about the manager.
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Will of the Council

Postby volrathxp » 12 Aug 2014, 00:32

RiiakShiNal wrote:
volrathxp wrote:I've looked at a few of the constant files in other DLC's, but I can't seem to really figure this out. How do I know that I've picked a number or register that isn't used by anyone else?
Constants are easy. You simply pick a name (usually all caps to indicate it's not going to change) and then equate it to something. As for picking the value usually you pick a pretty high value (but still less than 2 billion) usually starting with your reserved Id Block number and usually you're okay. For example since my Id Block is 8192 my constants for registers all start with 8192 (then I usually add a sequential number afterwards). Like my value for the target chest for Defending Player is 81920011. Most modders use low numbers for registers when creating cards (0, 1, 2, etc...), but for shared registers like the Duel Data Chest and the Player Data Chest use high numbers that are unlikely to be used by other people.

volrathxp wrote:I'm also a little fuzzy on the token manager.
Invisible managers get to be tricky, take a look at my custom Characteristics code for more information on how your manager would need to work. Your manager would not work quite the same as mine, but would need to be similar (you would be incrementing and clearing a value on the player instead of on a card). The good news is you would only need to worry about the manager for Brago's Representative and similar cards. If the card is only reading from the value and not modifying it then it doesn't have to worry about the manager.
So like I would just need something like this in a .LOL file?

CONSTANTS | Open
Code: Select all
VOTE_MODIFIER = 100011
I will look at your characteristics too, and let you know if I have any questions. I'm sure I will. Basically it just needs to clear VOTE_MODIFIER?

Edit: Of course... if I could *find* your token manager...

Edit: NVM Found it.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Next

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 1 guest

Main Menu

User Menu

Our Partners


Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 1 guest

Login Form