ajmath / xwing-vassal-utils

3 stars 1 forks source link

imagefix.rb error #1

Open gustavoberman opened 7 years ago

gustavoberman commented 7 years ago

Hi there! I'm having trouble with imagefix.rb, it downloads images, asks for confirmation on some image matches, but then exits with this error:

./imagefix.rb:220:in copy_match': undefined method[]' for nil:NilClass (NoMethodError) from ./imagefix.rb:261:in block in <main>' from ./imagefix.rb:241:ineach' from ./imagefix.rb:241:in `

'

I'm on ubuntu 16.04, ruby 2.3.1, and 7.1.0 vmod

Is there any way to fix it?

Thanks!

ajmath commented 7 years ago

Thanks for the report. I haven't been maintaining this with recent changes to vassal and don't plan on updating it going forward. I'm open to PRs if you're interested.

AlexRaubach commented 7 years ago

The problem is with R2-D2 astromech's match being nil and trying to call match[:path]. Here's what you get if you print out the vassal_card and match in the copy match function.

{:type=>"upgrades", :upgrade_type=>"Droid", :name=>"M9-G8", :clean_name=>"m9g8", :path=>"Up-M9_G8.jpg"}
{:type=>"upgrades", :path=>"/images/upgrades/amd/m9g8.png", :upgrade_type=>"amd", :name=>"m9g8", :clean_name=>"m9g8"}

{:type=>"upgrades", :upgrade_type=>"Droid", :name=>"R2-D2", :clean_name=>"r2d2", :path=>"Up-R2-D2.jpg"}
nil

I'll keep working on it and send a PR when I get it fixed.

AlexRaubach commented 7 years ago

https://github.com/voidstate/xwing-card-images/commit/7658d8959c16d7c0330eb4b50ae4c7d3024b89a3

Turns out Voidstate changed some card names to match the xws spec and the overrides file is still trying to match R2-D2 to the old card name.

gustavoberman commented 7 years ago

Hi there! Sorry, didn't check the response. Verified that r2d2 is the problem, I just removed from the ovverides.json and worked (I'm trying to understand how that files works) But also got some other "dual" cards that result in path 0 or 1 Also, I have some problem with the resulting packaging and vassal crashes when it tries to read it But if I do a zip of the resulting tree (stored in /tmp) vassal reads it ok I don't know anything on Ruby so I was using lost of puts to do some debug

gustavoberman commented 7 years ago

I did some ugly fix and added this:

    next if piece.parent["entryName"] == "Arc Caster (flippable)"
    next if piece.parent["entryName"] == "Adaptability (flippable)"
    next if piece.parent["entryName"] == "Intensity (flippable)"
    next if piece.parent["entryName"] == "Pivot Wing (flippable)"
    next if piece.parent["entryName"] == "CR90 Corvette Fore"
    next if piece.parent["entryName"] == "CR90 Corvette Aft"
    next if piece.parent["entryName"] == "Raider Class Corvette Fore"
    next if piece.parent["entryName"] == "Raider Class Corvette Aft"
AlexRaubach commented 7 years ago

I just wanted to let you know that I am still working on this, I have a forked repo where I'm switching to a regularly updated repository for the image source. I did notice that the output vmod file isn't working in vassal, but I haven't worked on fixing it yet. If you do find out, please let me know.

gustavoberman commented 7 years ago

Found a solution for the output file. I replaced the contents of zip_utils.rb for the sample showed here: https://github.com/rubyzip/rubyzip And modified to add the def self.extract_zip(file, destination) that is missing from that sample

AlexRaubach commented 7 years ago

Can you post your output file? I've tried to use the example zip functions but I'm still getting output that vassal won't accept

gustavoberman commented 7 years ago

Sorry for the delay in my response!

This is the file (remove the .txt):

zip_utils.rb.txt

And this are the ruby packages in my ubuntu 16.04 (perhaps there is some difference in libraries?)

ii  libruby2.3:amd64                                            2.3.1-2~16.04.2                               amd64        Libraries necessary to run Ruby 2.3
ii  rake                                                        10.5.0-2                                      all          ruby make-like utility
ii  ruby                                                        1:2.3.0+1                                     all          Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby-addressable                                            2.3.8-1                                       all          alternative URI implementation for Ruby
ii  ruby-bundler                                                1.11.2-1                                      all          Manage Ruby application dependencies (runtime)
ii  ruby-did-you-mean                                           1.0.0-2                                       all          smart error messages for Ruby > 2.3
ii  ruby-domain-name                                            0.5.20160216-2                                all          Domain Name manipulation library for Ruby
ii  ruby-http                                                   1.0.2-2ubuntu2                                all          easy-to-use client library for making http requests from Ruby
ii  ruby-http-cookie                                            1.0.2-1                                       all          Ruby library to handle HTTP Cookies based on RFC 6265
ii  ruby-http-form-data                                         1.0.1+gemwatch-1                              all          utility-belt to build form data request bodies
ii  ruby-http-parser.rb                                         0.6.0-3build4                                 amd64        Simple callback-based HTTP request/response parser
ii  ruby-json                                                   1.8.3-1build4                                 amd64        JSON library for Ruby
ii  ruby-minitest                                               5.8.4-2                                       all          Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii  ruby-molinillo                                              0.4.3-1                                       all          generic dependency resolution algorithm
ii  ruby-net-http-persistent                                    2.9.4-1                                       all          Manages persistent connections using Net::HTTP
ii  ruby-net-telnet                                             0.1.1-2                                       all          telnet client library
ii  ruby-nokogiri                                               1.6.7.2-3build1                               amd64        HTML, XML, SAX, and Reader parser for Ruby
ii  ruby-power-assert                                           0.2.7-1                                       all          library showing values of variables and method calls in an expression
ii  ruby-sqlite3                                                1.3.11-2build1                                amd64        SQLite3 interface for Ruby
ii  ruby-test-unit                                              3.1.7-2                                       all          unit testing framework for Ruby
ii  ruby-thor                                                   0.19.1-2                                      all          Ruby scripting framework
ii  ruby-unf                                                    0.1.4-1                                       all          Wrapper library to bring Unicode Normalization Form support to Ruby
ii  ruby-unf-ext                                                0.0.7.2-1build2                               amd64        Unicode Normalization Form support library for CRuby
ii  ruby-zip                                                    1.1.7-1                                       amd64        Ruby module for reading and writing zip files
ii  ruby2.3                                                     2.3.1-2~16.04.2                               amd64        Interpreter of object-oriented scripting language Ruby
ii  rubygems-integration                                        1.10                                          all          integration of Debian Ruby packages with Rubygems