Commit Graph

48 Commits (2733516cb9cdad7ac4cef98b819d4d01846e5c66)

Author SHA1 Message Date
Leandro Doctors 2733516cb9 Organize imports 2020-01-16 08:21:24 +08:00
Bilbo a6e97873fd Optimize mesage generation.
* Use faster stringbuilder for card token formatting instead of full-blown formatter.
* When SN/RN/PN and similar placeholders are expanded, calculate the replacement
  value only if the placeholder is present in the string.
   In a test with some random games:
    55.4M times replaceName was called
    39.2M times SN was present
     2.0M times PN was present
     0.2M times RN was present
     0.2M times X was present
* Generate event description on demand, instead on event construction.
   In a test with some random games:
   71.601M times description is generated
    0.258M time it is actually read or used
 By postponing generating the description to a point when it is actually needed,
 CPU time spent when going through possible actions is reduced to about 80%,
 so in given amount of time, MMAB AI and similar
 is able to examine larger part of the possible game states.
2019-12-13 05:25:23 +01:00
Martin Petricek bd5ae5fd7a Refactoring (#1543)
* Fix typos.

* Remove unnecessary boxing/unboxing.

* Replace traditional 'for' loops with 'foreach' loops.

* Replace explicit types with <> (diamonds) where they can be inferred.

* Collapse identical catch branches.

* Replace statement lambda with expression lambda for short statements.

* Remove unnecessary imports.

* Replace some lambdas with Comparator.comparing

* Replace Runnables with lambdas.

* Use addAll instead of adding whole collection manually.

* Simplify boolean expressions.

* Remove redundant 'else'.

* Simplify some boolean conditions that are always true or false.

* Inline redundant local variables.

* Remove extraneous semicolons.

* Fix Javadoc errors.

* Replace anonymous classes with lambdas.

* Replace chain of 'if's with switch.

* Remove delaration of exception that is never thrown.

* Use String/StringBuilder properly.
2018-04-08 08:59:14 +08:00
lodici 7abce85df1 remove unused import in MagicMessage. 2017-06-19 12:46:07 +01:00
melvinzhang f6ad5cbda8 Move image cache back to MagcImages while we figure out a better place for it
fix MessagePanel to use MagicImages

This reverts commit 4056d00ab7.
2017-05-15 19:56:58 +08:00
melvinzhang 9a608c0965 remove MessageViewerInfo and use MagicMesage directly
removed MagicPlayer from MagicMessage
2017-05-15 19:24:35 +08:00
lodici 1915195aeb Remove imports in same package. 2017-04-08 11:29:49 +01:00
melvinzhang 552a5fdae2 use getTokenizedCardNames to generate card names when returning cards from exile, fixes #1033 2017-01-15 09:42:00 +08:00
melvinzhang 97a5c98403 skip X indicator from mana cost if text contains 'where X' 2016-06-05 12:06:10 +08:00
melvinzhang a9694c6e34 replace String.format with MagicMessage.format 2016-01-31 12:44:03 +08:00
melvinzhang d4b6c54763 handle case of MagicCardChoiceResult in getCardToken instead of modifying toString method of MagicCardChoiceResult 2016-01-31 12:44:03 +08:00
melvinzhang c8f1262b45 remove trailing space from java code 2015-12-31 18:54:52 +08:00
melvinzhang 3186f9b3df only replace X not in quotes, fixes issue with Lavaclaw Reaches' text 2015-12-24 09:55:48 +08:00
melvinzhang efde000c3f show value of X in event description as 'X (<value>)', fixes #561 2015-12-14 09:22:49 +08:00
melvinzhang 0b05a0796f make 'face-down creature' interactive in log, fixes #477 2015-11-17 20:37:17 +08:00
melvinzhang aed7695e49 show RN as interactive link 2015-11-03 20:01:16 +08:00
lodici dd991744fa sort comma-separated string of tokenized cards names. 2015-10-30 20:35:51 +00:00
lodici 762e03d8a1 Display interactive card names in log for MillLibraryAction (see #480). 2015-10-30 20:16:43 +00:00
lodici 26e351d975 fix #474 : 1.66 crashes when there's more than one card face down. 2015-10-25 16:38:04 +00:00
lodici 27aa38b1e3 remove unnecessary MagicObject check. 2015-09-23 08:20:31 +01:00
lodici df355d4a96 Tokenize cards names returned from MagicCardChoiceResult. 2015-09-21 22:18:46 +01:00
lodici ff063cd6d9 simplify replaceName() now that getCardToken() accepts Object. 2015-09-21 20:33:12 +01:00
lodici 9c6e4cbc91 update MagicMessage.replaceChoices() to tokenize card names. 2015-09-21 19:54:19 +01:00
lodici 5336166c6c tokenize card name(s) in "...attacks with..." log message. 2015-09-19 19:00:55 +01:00
lodici 156a0f4d04 add code to replace SN with tokenized card name in log message. 2015-09-19 17:36:38 +01:00
lodici 656309a7a0 Change log message default font to plain; add code to parse card name token from log message. 2015-09-19 16:55:33 +01:00
melvinzhang 6cc4825510 moving handling of 'this thing' and 'that thing' from MagicMessage to MagicRuleEventAction
only PN, SN and RN should be done in MagicMessage as it is called on
custom description from groovy code as well
2015-04-10 13:44:10 +08:00
melvinzhang 6ebcf75f3c if 'it' is used and event has ref, return ref, else return source 2015-04-07 13:04:28 +08:00
melvinzhang b49a64ef19 allow 'that something' as an alias of RN 2015-04-07 11:46:14 +08:00
melvinzhang 7e5fb77dd2 match on word boundary instead of space 2015-04-04 13:31:08 +08:00
melvinzhang 08becf1bc1 allow 'this permanent', 'this creature', and 'it' as alias of SN 2015-04-02 10:38:44 +08:00
melvin 64368e1b9a remove extraneous whitespace 2013-06-24 09:33:35 +08:00
melvin f1b27c586c convert to UNIX line endings 2013-04-13 10:32:25 +08:00
melvin 5964a51cd5 existence of $ in test should be checked with indexOf >= 0 instead of indexOf > 0 2012-11-19 22:18:54 +08:00
melvin 04c4dbfa95 use for loop to handle management of idx 2012-11-19 22:07:45 +08:00
melvin 7e9055c558 fixed replaceChoices so that it can work with $ at end of the description 2012-11-19 21:59:53 +08:00
melvin 974beea067 replace RN with ref.toString() 2012-10-07 13:23:15 +08:00
melvin 9864cd3997 replace C style array delcaration with Java style 2012-09-28 16:09:47 +08:00
melvin dcc8d38484 optimized imports 2012-09-27 14:11:44 +08:00
melvin c2172bb85b replace names when storing description 2012-09-22 21:33:40 +08:00
melvin e637380b37 use SN and PN to refer to source name and player name in event description 2012-09-16 10:56:56 +08:00
melvin 534575121f PN will be replaced with player of the event 2012-09-16 10:32:36 +08:00
melvin acf6a0c73a only show choice if $ is present in description 2012-08-19 15:58:26 +08:00
melvin 14ccd4a165 convert tabs to four spaces 2012-06-16 22:55:26 +08:00
melvin 603705f6e3 minimize access 2011-09-10 21:41:43 +08:00
melvin 4340e775ea removed empty lines 2011-09-04 19:56:16 +08:00
melvin 850d01d3d1 optimized import statements with IntelliJ 2011-08-10 23:28:35 +08:00
ubeefx 7fd13965b2 Initial version. 2010-11-21 18:54:59 +00:00