[Utility] Card Hunter Battle Replayer

Discussion in 'Card Hunter General Chat' started by ParodyKnaveBob, Nov 8, 2017.

  1. ParodyKnaveBob

    ParodyKnaveBob Thaumaturge

    Well, good news and bad news. (I'd hoped to just bring good news, but here we are, ha ha.)

    The good news is that this week, I added ingestion of characters! $E^ b

    upload_2018-2-12_2-32-56.png

    Yes, they're showing in proper order and everything. $E^ J

    The bad news is that this is in Windows only. For some unknown reason, browsers are choking before they even get past the players, which they used to do fine.

    upload_2018-2-12_1-45-3.png

    That's in Edge, Chrome, and Firefox. Edge actually gives me a console error, but as per Microsoft norm, it's barely any info at all; Chrome and Firefox, though, surprised me with no console message describing this error. I'm sure I'll track it down eventually, but it kinda tarnishes my news. $;^ J Once I get this through, I'll feel better about uploading the Web app (which will still be super rough and sparse of any functionality anyway, lol).

    A touch more good news: I actually properly connect characters to their individual players! Also, I'm already laying groundwork as I go for more than just ranked play; I really hope to see that happen, although ranked is the easiest launch pad to start with of course. Finally, the main delays working with this this week have been due to my actually playing CH fairly regularly for the first time in months, heheheh.

    A touch more bad news: The players are actually not in order, ironically, (ironic since getting them is a prerequisite to properly getting the characters, who are in order, ha,) but replacing this earlier shortcut with properly ordered design will probably be my next task; the big question is how much I want to build now for team play behind the scenes vs. taking shortcuts again and postponing structuring full teams for later. Also, I have a loose idea for ingesting characters' classes, but I'm not entirely looking forward to it. $E^ b (Finally, just before posting, I wound up playing with a couple other logs, and huh, there's a mistake somewhere that I guess just snuck under my main testing log's radar due to coincidence. Once I find and fix that, it might auto-fix that undefined problem. We'll see.)

    So, to be clear about the yaaay screenshot, @candilicous is actually Player 1 and I Player 2, thus the tool has that wrong, but candilicous' P1 chars are properly first, in order from left to right, and my P2 chars come properly second, also in order from left to right. $:^ ] (This will hopefully be useful in the future for handling logs with insane players who name their characters all the same. Right now, they simply invalidate. Whatcha gonna do. At least I've already accounted for chars named the same as players!)

    All right! I'd better get outta here before this text wall grows too high. Let's see what next week holds.
     
    Last edited: Feb 12, 2018 at 2:42 AM
    winner, Happenstance and Sir Veza like this.
  2. Kalin

    Kalin Begat G'zok

    Just watch for the first card they draw, right?
     
    winner likes this.
  3. ParodyKnaveBob

    ParodyKnaveBob Thaumaturge

    No, unfortunately. (However, that's the amazingly easy race determiner! heehee ... at least until fixed leagues and adventures.)
     
    winner likes this.
  4. ParodyKnaveBob

    ParodyKnaveBob Thaumaturge

    Back already! Just wanted to say more good-news-bad-news: I found the (surprisingly weird) area where the bug hid and managed to squash it! -- but only for Windows. $F^ b Unfortunately, still gotta track the (apparently different) problem on HTML5.

    I could've waited for the weekend (and until I fixed it in browsers) before saying that, but I wanted to clarify/expand my response to @Kalin:

    Amazingly simple design, yes. In fact, this is the entire script I wrote to determine race:

    PHP:
    /// str_race = scr_log_race_from_racial(text);
    /*
    purpose: determine a char's race from its racial card (if at all possible)
    scope: inst_ctrl_main
    //NEW: currently assumes for ranked parties, but later, handle leagues & monsters

    0 str: text to parse
    return str: race of char
    */

    switch (argument0) {
        case 
    "Walk":
            return 
    "Dwarf";
        case 
    "Run":
            return 
    "Human";
        case 
    "Dash":
            return 
    "Elf";
        default:
            return 
    "<Unknown>";
    }
    But, don't let my glee over that fool ya. This is the chunk I wrote to actually get the racial card in the first place (with only string_pos() and string_delete() being built-in functions -- and custom Hungarian Systems/Apps because weak-typed language -- not actually PHP, but using that BBCode code block for nicer readability):

    PHP:
    //% try easiest way to get character names, races, and players %//
    if (_str_room != undefined  &&  string_pos(" vs "_str_room)) { // ranked or league only
        
    _index_line_next scr_log_find_line("Event=Draw Phase Initiated");
        if (
    _index_line_next != INDEX_LIST_NOT_FOUND) {
            
    _index_line_end scr_log_find_line("Event=Action Phase Initiated"_index_line_next);
            if (
    _index_line_end != INDEX_LIST_NOT_FOUND) {
                while (++
    _index_line_next _index_line_end) {
                    
    _i_player = -1;
                    
    repeat (_count_players) {
                        if (
    scr_log_str_pos(map_battle_players[? ++_i_player], _index_line_next_index_name_begin) == _index_name_begin) {
                            
    //% get race from racial card, then char name, then skim lines until char name changes (for now, same-name chars invalidate) %//
                            
    _index_pos_start _index_name_begin string_length(map_battle_players[? _i_player] + " drew ");
                            
    _index_pos_end scr_log_str_pos(" for "_index_line_next_index_pos_start) - 1;
                            
    _str_race scr_log_race_from_racial(scr_log_get_text(_index_line_next_index_pos_start_index_pos_end));
                            
    _str_name scr_log_get_text(_index_line_next,  _index_pos_end 6); // 6: advance pointer by 1 + length of " for "
                            
    while (scr_log_str_pos(_str_name, ++_index_line_next_index_pos_start)) { // start after player name because some name chars after players!
                            
    }
                            --
    _index_line_next// prep for outside while() loop
                            
    scr_log_grid_char_new(_i_player_str_name_str_race);
                            break;
                        }
                    }
                }
            }
        }
    }
     
    Last edited: Feb 13, 2018 at 1:21 PM
    winner, Sir Veza and Flaxative like this.

Share This Page