• R/O
  • SSH
  • HTTPS

jinrousiki: Commit


Commit MetaInfo

Révision2757 (tree)
l'heure2021-07-23 05:02:47
Auteurumethyl

Message de Log

JinrouStatistics:実験コード登録

Change Summary

Modification

--- trunk/dev/test/data/vote_debug.php (revision 2756)
+++ trunk/dev/test/data/vote_debug.php (revision 2757)
@@ -42,3 +42,150 @@
4242 //DB::Connect(); DB::d();
4343 //$q = Query::Init()->Table('user_entry')->Select(['user_no'])->Where(['room_no']);
4444 //$q->p();
45+
46+class JinrouStatistics extends StackStaticManager {
47+ public static function GetRoom() {
48+ DB::Connect();
49+ RQ::Get()->page = 'all';
50+ foreach (RoomLoaderDB::GetFinished(false) as $room_no) {
51+ DB::SetRoom(RoomLoaderDB::LoadFinished($room_no));
52+ DB::$ROOM->ParseOption();
53+ $stack = self::GetCategoryStack();
54+ self::UpdateRoom($stack);
55+ #Text::p($stack);
56+ }
57+ #Text::p(DB::$ROOM);
58+
59+ self::OutputCategory();
60+ self::OutputCategoryWin();
61+ }
62+
63+ //村の種別を判定して専用スタックを取得する
64+ private static function GetCategoryStack() {
65+ $category = self::DecideRoomCategory();
66+ $stack = self::Stack();
67+ if ($stack->IsEmpty($category)) {
68+ $stack->Set($category, new Stack());
69+ $stack->Get($category)->Set('category', $category);
70+ }
71+ return $stack->Get($category);
72+ }
73+
74+ //村の種別判定
75+ private static function DecideRoomCategory() {
76+ //特殊村判定
77+ foreach (self::GetSpecialCategoryList() as $option) {
78+ if (DB::$ROOM->IsOption($option)) {
79+ return $option;
80+ }
81+ }
82+
83+ //闇鍋モード判定
84+ foreach (OptionFilterData::$group_chaos as $option) {
85+ if (DB::$ROOM->IsOption($option)) {
86+ return 'chaos';
87+ }
88+ }
89+
90+ return 'normal';
91+ }
92+
93+ //特殊村判定オプション一覧取得
94+ private static function GetSpecialCategoryList() {
95+ //OptionFilterData に登録してもいいかもしれない
96+ return ['duel', 'gray_random', 'quiz'];
97+ }
98+
99+ //村の統計情報登録
100+ private static function UpdateRoom(Stack $stack) {
101+ $stack->AddNumber('room', 1);
102+ $stack->AddNumber('date', DB::$ROOM->date);
103+ $stack->AddNumber('user_count', DB::$ROOM->user_count);
104+
105+ $category = 'winner';
106+ if ($stack->IsEmpty($category)) {
107+ $filter = new Stack();
108+ $stack->Set($category, $filter);
109+ } else {
110+ $filter = $stack->Get($category);
111+ }
112+ $winner = DB::$ROOM->winner;
113+ if (null === $winner) {
114+ $winner = WinCamp::NONE;
115+ }
116+ $filter->AddNumber($winner, 1);
117+ }
118+
119+ //カテゴリ別統計出力
120+ private static function OutputCategory() {
121+ TableHTML::OutputHeader('');
122+ TableHTML::OutputTh('種別');
123+ TableHTML::OutputTh('総数');
124+ TableHTML::OutputTh('日数');
125+ TableHTML::OutputTh('人数');
126+ $stack = self::Stack();
127+ foreach (self::GetCategoryList() as $category => $name) {
128+ TableHTML::OutputTrHeader();
129+ TableHTML::OutputTd($name);
130+ if ($stack->IsEmpty($category)) {
131+ $filter = new Stack();
132+ } else {
133+ $filter = $stack->Get($category);
134+ }
135+ foreach (['room', 'date', 'user_count'] as $data) {
136+ if ($filter->IsEmpty($data)) {
137+ $number = 0;
138+ } else {
139+ $number = $filter->Get($data);
140+ }
141+ TableHTML::OutputTd($number);
142+ }
143+ TableHTML::OutputTrFooter();
144+ }
145+ TableHTML::OutputFooter();
146+ }
147+
148+ //カテゴリ別勝利陣営統計出力
149+ private static function OutputCategoryWin() {
150+ foreach (self::GetCategoryList() as $category => $name) {
151+ Text::p($name);
152+ $stack = self::Stack()->Get($category);
153+ if (null === $stack) {
154+ continue;
155+ }
156+
157+ TableHTML::OutputHeader('');
158+ $camp_list = (new ReflectionClass('WinCamp'))->getConstants();
159+ $filter = $stack->Get('winner');
160+ Text::p($filter);
161+ foreach ($camp_list as $camp) {
162+ if ($filter->Exists($camp)) {
163+ TableHTML::OutputTh(RoleDataManager::GetName($camp));
164+ }
165+ }
166+ TableHTML::OutputTrFooter();
167+
168+ TableHTML::OutputTrHeader();
169+ foreach ($camp_list as $camp) {
170+ if ($filter->Exists($camp)) {
171+ TableHTML::OutputTd($filter->$camp);
172+ }
173+ }
174+ TableHTML::OutputTrFooter();
175+ TableHTML::OutputFooter();
176+ }
177+ }
178+
179+ //カテゴリリスト取得
180+ private static function GetCategoryList() {
181+ return [
182+ 'normal' => '普通',
183+ 'chaos' => '闇鍋',
184+ 'duel' => '決闘',
185+ 'gray_random' => 'グレラン',
186+ 'quiz' => 'クイズ',
187+ ];
188+ }
189+}
190+
191+JinrouStatistics::GetRoom();
Afficher sur ancien navigateur de dépôt.