new_global_tutor: return values, return tutored card
Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!
PLEASE DO NOT REPORT BUGS HERE!
Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins
new_global_tutor: return values, return tutored card
by FastEddie » 16 Aug 2020, 15:57
I had a closer look at new_global_tutor() related to these two bug fixes:
https://www.slightlymagic.net/forum/viewtopic.php?f=86&t=29382
https://www.slightlymagic.net/forum/viewtopic.php?f=86&t=21113
It turned out that I didn't properly understand the function (to be expected). Therefore this little write-up. The same stuff can be found in tutors.c.
new_global_tutor has the following return values:
Based on that I rewrote Saheeli Rai, Three Dreams and Uncage the Menagerie in a way that is more in line with what the developers intented when writing new_global_tutor. Gifts Ungiven is indeed different as the cards go to a separate zone in the meanwhile, therefore I didn't touch it (it needs a little clean-up, will do this seperately).
Saheeli Rai:
https://www.slightlymagic.net/forum/viewtopic.php?f=86&t=29382
https://www.slightlymagic.net/forum/viewtopic.php?f=86&t=21113
It turned out that I didn't properly understand the function (to be expected). Therefore this little write-up. The same stuff can be found in tutors.c.
new_global_tutor has the following return values:
- -1 if tutoring got cancelled (manually or because the test didn't pass)
Otherwise:
- If test.qty > 1: number of cards that were actually tutored
If test.qty == 1: some positive number if turoting was succesful
Based on that I rewrote Saheeli Rai, Three Dreams and Uncage the Menagerie in a way that is more in line with what the developers intented when writing new_global_tutor. Gifts Ungiven is indeed different as the cards go to a separate zone in the meanwhile, therefore I didn't touch it (it needs a little clean-up, will do this seperately).
Saheeli Rai:
- Code: Select all
if( choice == CHOICE_THREE_ARTIFACTS ){
int chosen[3] = {-1, -1, -1};
test_definition_t test;
default_test_definition(&test, TYPE_ARTIFACT);
test.value_for_special_selection_function = (int)chosen;
test.special_selection_function = test_not_in_array3;
test.qty = 1;
test.no_shuffle = 1;
test.storage = card;
int num_chosen;
for (num_chosen = 0; num_chosen < 3; ++num_chosen)
{
if (ai_is_speculating != 1){
sprintf(test.message, "Select up to three artifact cards with different names. Card #%d of up to 3", num_chosen + 1);
}
int pos = new_global_tutor(player, player, TUTOR_FROM_DECK, TUTOR_HAND, 0, AI_MAX_CMC, &test);
if (pos > -1) {
chosen[num_chosen] = get_card_instance(player, card)->targets[0].card;
} else {
break;
}
remove_card_from_deck(player, pos);
}
shuffle(player);
}
- Code: Select all
if (event == EVENT_RESOLVE_SPELL ){
int chosen[3] = {-1, -1, -1};
int num_chosen;
test_definition_t test;
default_test_definition(&test, TYPE_ENCHANTMENT);
test.no_shuffle = 1;
test.value_for_special_selection_function = (int)chosen;
test.special_selection_function = test_not_in_array3;
test.storage = card;
for (num_chosen = 0; num_chosen < 3; ++num_chosen){
if (ai_is_speculating != 1){
sprintf(test.message, "Select up to three Aura cards with different names. Card #%d of up to 3", num_chosen + 1);
}
int pos = new_global_tutor(player, player, TUTOR_FROM_DECK, TUTOR_HAND, 0, AI_MAX_VALUE, &test);
if (pos > -1) {
chosen[num_chosen] = get_card_instance(player, card)->targets[0].card;
} else {
break;
}
remove_card_from_deck(player, pos);
}
shuffle(player);
kill_card(player, card, KILL_DESTROY);
}
- Code: Select all
if( event == EVENT_RESOLVE_SPELL ){
card_instance_t* instance = get_card_instance(player, card);
if( instance->info_slot > 0){
int chosen[20];
memset( chosen, -1, sizeof(chosen) );
int num_chosen;
for (num_chosen = 0; num_chosen < instance->info_slot; ++num_chosen){
test_definition_t test;
char buffer[100];
scnprintf(buffer, 100, "Select creature cards with different names that each have CMC %d. Card %d of up to %d", instance->info_slot, (num_chosen+1), instance->info_slot);
new_default_test_definition(&test, TYPE_CREATURE, buffer);
test.cmc = instance->info_slot;
test.value_for_special_selection_function = (int)chosen;
test.special_selection_function = test_not_in_array20;
test.no_shuffle = 1;
test.storage = card;
int pos = new_global_tutor(player, player, TUTOR_FROM_DECK, TUTOR_HAND, 0, AI_MAX_VALUE, &test);
if (pos > -1) {
chosen[num_chosen] = get_card_instance(player, card)->targets[0].card;
} else {
break;
}
remove_card_from_deck(player, pos);
}
shuffle(player);
}
kill_card(player, card, KILL_DESTROY);
}
- Attachments
-
- tutors.zip
- (845 Bytes) Downloaded 205 times
-
- ravnica.zip
- (949 Bytes) Downloaded 208 times
-
- kaladesh.zip
- (788 Bytes) Downloaded 203 times
-
- hour_of_devastation.zip
- (653 Bytes) Downloaded 202 times
---
Argivian Archaeologist in the Library of Leng studying the Spells of the Ancients
Argivian Archaeologist in the Library of Leng studying the Spells of the Ancients
Re: new_global_tutor: return values, return tutored card
by Aswan jaguar » 23 Aug 2020, 16:45
Does new_global_tutor add anything more to these cards so to commit them again?
If not they are good as they are.
If not they are good as they are.
---
Trying to squash some bugs and playtesting.
Trying to squash some bugs and playtesting.
-
Aswan jaguar - Super Tester Elite
- Posts: 8080
- Joined: 13 May 2010, 12:17
- Has thanked: 731 times
- Been thanked: 458 times
Re: new_global_tutor: return values, return tutored card
by FastEddie » 23 Aug 2020, 17:32
No, it just streamlined the code. new_global_tutor should do the job, no need to work around with select_card_from_hand. But Drool66 informed me that these don't work (which is weird because in my local version it did), so something changed in the background. I will into that again and give an update here.
---
Argivian Archaeologist in the Library of Leng studying the Spells of the Ancients
Argivian Archaeologist in the Library of Leng studying the Spells of the Ancients
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests