Tuesday, October 13, 2020

Change Docker Container localtime

There are 5 ways to change docker container' locatime, i chose
-v /etc/localtime:/etc/localtime:ro

Short blog, happy post ^^

Monday, September 28, 2020

Linux Generate md5 from command line

`echo` would always return with trailing new line char, therefore pass `-n` to
neglect the newline. And so md5sum would received a text from pipe with `-t`
option

 $ echo -n 123456 | md5sum -t

e10adc3949ba59abbe56e057f20f883e  -

Have fun ^^

Sunday, September 27, 2020

XMage, Adding MutateAbility (2)

Got the ETB triggers, by using the 

Ability abilityEquip = new EntersBattlefieldTriggeredAbility(
    new MutateEffect(Outcome.Mutate)
); 
abilityEquip.addTarget(targetNonHuman);
this.addAbility(abilityEquip);

While the MutatesSourceTriggeredAbility failed to trigger..
or probably it is triggered but there is something in the GameImpl
that treated it different way?

Saturday, September 26, 2020

Xmage, Client does not want to Run, as the Card Repository broken or error

If you experience the Card db or repository failure, then simply
Make sure you are in the Mage.Client dir 

$ pwd 
mage/Mage.Client

$ rm -rf db

And then re-run the client,
$ mvn exec:java -Dexec.mainClass="mage.client.MageFrame"

Hope it helps ^^

Friday, September 25, 2020

XMage, Setting Client And Server to TestMode

Mage.Client, go to SessionHandler.java and edit

public static boolean isTestMode() {

	return true;
    //return session.isTestMode();
}

Mage.Server, run is with additional argument set, -testMode=true


$ mvn exec:java -Dexec.mainClass="mage.server.Main" -Dexec.args="-testMode=true"

Happy testing ^^

XMage, Adding MutateAbility (1)

 Got gp66 forked repo to work on. Trying to test Gemrazer to implement

1. target controlled permanent non-human

@@ -2,36 +2,48 @@ package mage.cards.g;
 
 import mage.MageInt;
 import mage.abilities.Ability;
 import mage.abilities.common.MutatesSourceTriggeredAbility;
 import mage.abilities.effects.common.DestroyTargetEffect;
+import mage.abilities.effects.common.AttachEffect;
 ...
 import mage.constants.CardType;
+import mage.constants.Outcome;
 import mage.constants.SubType;
 import mage.constants.TargetController;
 import mage.filter.FilterPermanent;
 import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
+import mage.filter.common.FilterControlledCreaturePermanent;
 import mage.target.TargetPermanent;
+import mage.constants.SubType;
+import mage.filter.predicate.Predicates;

...
 
public final class Gemrazer extends CardImpl {
 
-    private static final FilterPermanent filter
+	private static final FilterPermanent filter
             = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment an opponent controls");
 
     static {
         filter.add(TargetController.OPPONENT.getControllerPredicate());
     }
 
+    private static final FilterPermanent filterCreatureNonHuman
+            = new FilterControlledCreaturePermanent("non-human creature you control");
+    
+    static {
+    	filterCreatureNonHuman.add(Predicates.not(SubType.HUMAN.getPredicate()));
+    }
+

@@ -43,10 +55,15 @@ public final class Gemrazer extends CardImpl {
         // Reach
         this.addAbility(ReachAbility.getInstance());
 
         // Trample
         this.addAbility(TrampleAbility.getInstance());
+        
+        // Whenever this creature mutates, attach to a controlled non-human creature
+        Ability abilityAttach = new MutatesSourceTriggeredAbility(new AttachEffect(Outcome.Mutate));
+        abilityAttach.addTarget(new TargetPermanent(filterCreatureNonHuman));
+        this.addAbility(abilityAttach);
 
         // Whenever this creature mutates, destroy target artifact or enchantment an opponent controls.
         Ability ability = new MutatesSourceTriggeredAbility(new DestroyTargetEffect());
         ability.addTarget(new TargetPermanent(filter));
         this.addAbility(ability);

2. Test the ability of mutated creature

 @Test
    public void testCastMutate() {
        addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
        addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
        addCard(Zone.BATTLEFIELD, playerA, "Flourishing Fox",1);
        addCard(Zone.HAND, playerA, "Gemrazer",1);

        castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gemrazer using mutate");
        // But why no addTarget to flourishing fox ??
        
        setStrictChooseMode(true);
        setStopAt(1, PhaseStep.BEGIN_COMBAT);
        execute();
        assertAllCommandsUsed();

        assertAbility(playerA, "Gemrazer", new CyclingAbility(new ManaCostsImpl("{1}")), true);
        assertHandCount(playerA, 0);
    }

The test result so far so good

Todo:

Ask for the mutation on top or bottom of the targeted non-human creature.


Eclipse Maven build, recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0`

Error at Eclipse build, "... recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0`"

Solution:

Find your .m2 repository dir, in my Linux debian 10 is at ~/.m2

$ find . -name "<your-project-org.xxx.xxx.projectname>"
$ rm -f org/<your-project-org.xxx.xxx.projectname> <-- usually under the name of your project

at the command line of the project, 

$ mvn clean
$ mvn install -DskipTests=true

Reopen eclipse, reference here

select Porject -> Maven -> Update

Have fun ^^

Monday, July 13, 2020

Failed to install the following Android SDK packages as some licences have not been accepted.



Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-28 Android SDK Platform 28 If you stumbled upon the same error, then you could try these:

`yes | ./sdkmanager "platforms;android-28"`
`yes | ./sdkmanager "build-tools;28.0.3"`
`yes | ./sdkmanager --licenses`
You could find your sdkmanager executeable in linux by

$ locate sdkmanager

or

$ find / -name "sdkmanager"

Hope it helps.

Tuesday, June 16, 2020

ReactNative OneSignal Android failed to compile RNOneSignal.java because bunch of unhandled JSONException

If you compile ReactNative Android OneSignal plugin and hit the unhandled
JSONException that thrown or triggered by 
callback.invoke(RNUtils.jsonToWritableMap(outcomeEvent.toJSONObject()));

Simply add this:
-- callback.invoke(RNUtils.jsonToWritableMap(outcomeEvent.toJSONObject()));

++ try {
++     callback.invoke(RNUtils.jsonToWritableMap(outcomeEvent.toJSONObject()));
++ }
++ catch (JSONException je ) {
++     je.printStackTrace();
++     return;
++ }

Hope it help ^^

Wednesday, April 15, 2020

Linux Panda3D, ImportError: No module named direct.directbase.DirectStart

What to do if you see the Error Message:
ImportError: No module named direct.directbase.DirectStart
This error means it couldn’t find the Python modules – please make sure you are running the correct version of Python (probably Python 3.7, that depends on the Panda3D version) and that the panda3d.pth is located inside the Python site- packages directory.

I got this problem during Panda3D Linux installation. Searching for panda3d.pth also
can not be found. So this is what i done to get the installation to work.
1. follow all steps in the Panda3D website
2. My system is Debian 10 64bit,
    a file panda3d1.10_1.10.0_amd64.deb created
3. After sudo dpkg -i panda3d1.10_1.10.0_amd64.deb
4. set $PYTHONPATH in ~/.bashrc
    export PYTHONPATH=/opt/pythonprj/panda3d/panda3d-src/built:$PYTHONPATH
*/ 'built' depends to the directory where one compile or execute this
    python makepanda/makepanda.py --everything --installer
5. then run the environment by execute $ source ~/.bashrc or exit the terminal
    and relaunch, check with $ echo $PYTHONPATH, shud show the dir set at #4
6.
$ python
Python 3.6.9 (default, Dec 19 2019, 01:20:01) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from direct.showbase.ShowBase import ShowBase
>>>

it works! ^^

Thursday, April 9, 2020

Debian Linux, Wifi disconnect frequently

Just feel so bored with the same problem over and over again, it is my internal Wifi.
It keeps disconnecting frequently. I bought a USB Wifi dongle and it also does not
help very much.

After some googling and found out that there is wifi.powersafe option that could be
set to disabled wifi power safe, link. Immediately set the conf file

$ sudo vim /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

add this in the file if blank:

[connection]
wifi.powersave = 2

And if there is entries, then try to look for the above option and set to 2.
Which you could check for each of the options are

NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave NM_SETTING_WIRELESS_POWERSAVE_ENABLE (3): enable powersave

Then restart the NetworkManager

$ systemctl restart network-manager

My wifi is now working smoothly ^^