Last active
February 21, 2019 08:05
-
-
Save sasairc/d1b80d3c1c7d1087b51d5df79eaabe8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "./gasha.h" | |
#include <stdio.h> | |
//#define VERBOSE | |
int main(void) | |
{ | |
size_t i = 0; | |
GASHA* gasha = NULL; | |
GASHA_CARD* result = NULL; | |
GASHA_CARD cards[] = { | |
/* | |
* ★★★ | |
*/ | |
{3001, "ゆの(ナイト)", 3}, | |
{3002, "ゆの(アルケミスト)", 3}, | |
{3003, "宮子(ナイト)", 3}, | |
{3004, "宮子(まほうつかい)", 3}, | |
{3005, "ヒロ", 3}, | |
{3006, "沙英", 3}, | |
{3007, "乃莉", 3}, | |
{3008, "なずな", 3}, | |
{3009, "トオル(まほうつかい)", 3}, | |
{3010, "トオル(アルケミスト)", 3}, | |
{3011, "るん(まほうつかい)", 3}, | |
{3012, "るん(アルケミスト)", 3}, | |
{3013, "ユー子(せんし)", 3}, | |
{3014, "ユー子(そうりょ)", 3}, | |
{3015, "ナギ(そうりょ)", 3}, | |
{3016, "ナギ(ナイト)", 3}, | |
{3017, "涼風 青葉(せんし)", 3}, | |
{3018, "涼風 青葉(ナイト)", 3}, | |
{3019, "滝本 ひふみ(せんしト)", 3}, | |
{3020, "滝本 ひふみ(そうりょ)", 3}, | |
{3021, "篠田 はじめ", 3}, | |
{3022, "飯島 ゆん", 3}, | |
{3023, "八神 コウ", 3}, | |
{3024, "遠山 りん", 3}, | |
{3025, "阿波根 うみこ", 3}, | |
{3026, "折部 やすな", 3}, | |
{3027, "ソーニャ", 3}, | |
{3028, "呉織 あぎり", 3}, | |
{3029, "桜ノ宮 苺香", 3}, | |
{3030, "日向 夏帆", 3}, | |
{3031, "星川 麻冬", 3}, | |
{3032, "天野 美雨", 3}, | |
{3033, "神崎 ひでり", 3}, | |
/* | |
* ★★★★ | |
*/ | |
{4001, "ゆの", 4}, | |
{4002, "宮子", 4}, | |
{4003, "ヒロ", 4}, | |
{4004, "沙英", 4}, | |
{4005, "乃莉", 4}, | |
{4006, "なずな", 4}, | |
{4007, "トオル", 4}, | |
{4008, "るん", 4}, | |
{4009, "ユー子", 4}, | |
{4010, "ナギ", 4}, | |
{4011, "ミホ", 4}, | |
{4012, "涼風 青葉", 4}, | |
{4013, "滝本 ひふみ", 4}, | |
{4014, "篠田 はじめ", 4}, | |
{4015, "八神 コウ", 4}, | |
{4016, "遠山 りん", 4}, | |
{4017, "阿波根 うみこ", 4}, | |
{4018, "星川 ほたる", 4}, | |
{4019, "呉織 あぎり", 4}, | |
{4020, "桜ノ宮 苺香", 4}, | |
{4021, "日向 夏帆", 4}, | |
{4022, "星川 麻冬", 4}, | |
{4023, "天野 美雨", 4}, | |
{4024, "神崎 ひでり", 4}, | |
{4025, "有馬 ひづめ", 4}, | |
{4026, "猿渡 宇希", 4}, | |
{4027, "舘島 虎徹", 4}, | |
{4028, "牛久 花和", 4}, | |
/* | |
* ★★★★★ | |
*/ | |
{5001, "ゆの", 5}, | |
{5002, "宮子", 5}, | |
{5003, "トオル", 5}, | |
{5004, "るん", 5}, | |
{5005, "ユー子", 5}, | |
{5006, "ナギ", 5}, | |
{5007, "涼風 青葉", 5}, | |
{5008, "滝本 ひふみ", 5}, | |
{5009, "折部 やすな", 5}, | |
{5010, "ソーニャ", 5}, | |
{5011, "桜ノ宮 苺香", 5}, | |
{5012, "星川 麻冬", 5}, | |
{5013, "鳩谷 こはね", 5}, | |
{0, NULL, 0}, | |
}; | |
init_gasha(&gasha); | |
gasha->join_cards(&gasha, cards); | |
gasha->change_weight(&gasha, RARITY_R, 86); | |
gasha->change_weight(&gasha, RARITY_SR, 12); | |
gasha->change_weight(&gasha, RARITY_SSR, 2); | |
#ifdef VERBOSE | |
fprintf(stdout, "**** probabilities ****\n"); | |
fprintf(stdout, "rarity = 3, weight = %02d%\nrarity = 4, weight = %02d%\nrarity = 5, weight = %02d%\n", | |
gasha->conf->weights[RARITY_R], gasha->conf->weights[RARITY_SR], gasha->conf->weights[RARITY_SSR]); | |
fprintf(stdout, "\n**** cards ****\n"); | |
for (i = 0; i < gasha->cardc; i++) { | |
fprintf(stdout, "id = %d, name = %s, rarity = %d\n", | |
gasha->card[i]->id, gasha->card[i]->name, gasha->card[i]->rarity); | |
} | |
putchar('\n'); | |
/* VERBOSE */ | |
#endif | |
if (gasha->is_ready(gasha)) { | |
for (i = 1; i <= 10; i++) { | |
if (i % 10 == 0) | |
result = id2card(gasha, gasha->roll10(gasha)); | |
else | |
result = id2card(gasha, gasha->roll(gasha)); | |
if (result->rarity == 5) | |
fprintf(stdout, "%zu 回目の試行で 星%d の %s が当たりました。やったね!\n", | |
i, result->rarity, result->name); | |
else | |
fprintf(stdout, "%zu 回目の試行で 星%d の %s が当たりました。\n", | |
i, result->rarity, result->name); | |
} | |
} | |
gasha->release(gasha); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment