休闲玩家的「口袋妖怪·走」的入门心得

总之 Pokémon Go 也是开服几天了,赶时髦玩了一玩,总之是勾引宅男出门锻炼的好游戏。这游戏的教学系统不可谓不烂,进去之后几天下来走了不少弯路,那么记录一下也许可以帮助其他人。

1、精灵捕捉

你以为的 pokemon go 是这样的:

CnPyrCjWYAAYfOa

其实是这样的:

CnNBjtPUEAAstJL

但是不要小看拉达和波波。游戏中等级是十分重要的,升级的途径是获得经验。而获得经验的途径有以下几种:

  • 捕捉精灵(100exp + 10exp 取决于扔球姿势)
  • 获得新精灵图鉴(500exp)
  • 对战(胜利一次好像是100?)
  • 进化(500exp)
  • pokestop(50exp)

进化需要获得这个精灵家族的糖果,糖果的获得方式是:

  • 捕捉(3)
  • 孵化(10-25,可能取决于种类)
  • 放走(说明是传送给博士,1)

拉达进化需要 25,比比鸟进化需要 12。而进化比雕需要 50。想要刷经验的话,拼命捕捉波波和拉达就可以获得大量经验,可不要忽视了。

对战获得的经验其实不是非常可持续性,因为并没有自动回血/复活这样的设定。

另外坐在原地是几乎不可能刷新精灵的,除非周围有人用 lure module 或者自己使用吸引精灵的道具。

我曾经尝试原地并使用吸引精灵的道具,30分钟的时间内只有 4 只,lure module 我坐在原地刷新则奇快。

2、道具

pokestop 刷新时间其实极短(几分钟),找到有多个 pokestop 聚集的地点可以快速刷道具和经验。

hp 0 只能复活,然而这时如果对气绝的精灵使用 power up 则会增加 hp 反而直接活过来,则不能使用复活药回血。复活药回血有时更加划算(50% hp),精灵血多(hp > 40)的时候优先复活,否则优先升级。

3、对战

打不过就跑是很重要的,即使跑了也可以获得经验,而不用浪费 hp 在打不过的精灵上。

4、技能

我查了半天才发现必杀技能是长按释放(未测试)。攻击需要使用加藤鹰之指拼命点屏幕。每种技能频率好像不同,有些频率快的技能(大概多是低攻击力的?)需要拼命点屏才能获得高伤害。闪避躲必杀可能才比较划算。

精灵进化之后技能是会再随机刷新的!获得好技能的未进化精灵大概毫无意义!

技能选择上要注意属性!

5、属性

精灵肯定有个体值差异,并且会影响最大 CP,目前和体重之间的关系不明。然而需要注意的是最大的 CP 也和你自己等级挂钩,所以拼命升级也是很重要的。

不要浪费 Stardust 在低初始 CP 的精灵上,Stardust 是稀缺资源。高初始 CP 的精灵在你高等级之后十分容易刷出。

6、选择精灵

拉达属性实在不够看……比雕还不错,算是初期易于获得的精灵之一,可以容易刷到 500 CP 去战一场。

7、等级的影响

  • 精灵出现种类?似乎有些精灵在我低等级时并不出现。
  • CP 最大值(升一级可以多 power up 1-2 次)
  • 升级赠送道具
  • 野生精灵 CP (我现在很少见到 10 CP 的了……)

8、对战

捡软柿子打,不要浪费 HP 在打不过的人上。例如你有 500 CP 的精灵 1只,其他 5 只都是低 CP,道馆有 200 和 800 的。你打败 200 的就能降低 1000 道馆的进度。每 4000 进度增加一个人。也就是说踢出去一个人,你之后要打的精灵数量就减少。对于我这种当单机玩的人来说是一种节省药品的方式。

刷自己阵营的道馆的空位也可以使用类似方式节省药。占领道馆位置才能刷 20 小时一次的游戏币和 Stardust。

9、阵营选择

本地急冻鸟阵营人最多,从外形上其实可以预测吧,我推测世界上其他地方也是类似…选择人多的还是人少的就见仁见智了。

Posted in 日志 | Tagged | Leave a comment

One bad API in sd-bus

I’m using sd-bus to develop the dbus part for fcitx5, because I’d like to seamlessly support kdbus in the future. (Don’t argue with me about bsd or sth else right now, for now I don’t care about that.)

But one api of sd-bus obviously blows up my mind.

https://github.com/systemd/systemd/blob/09541e49ebd17b41482e447dd8194942f39788c0/src/systemd/sd-bus.h#L428

typedef int (*sd_bus_track_handler_t) (sd_bus_track *track, void *userdata);
int sd_bus_track_new(sd_bus *bus, sd_bus_track **track, sd_bus_track_handler_t handler, void *userdata);

So basically, it’s a wrapper around NameOwnerChanged dbus signal. And let you get notification about when the service disappears (only disappears, yeah).

And it also has capability to track more than one service name by using.

int sd_bus_track_add_sender(sd_bus_track *track, sd_bus_message *m);
int sd_bus_track_remove_sender(sd_bus_track *track, sd_bus_message *m);
int sd_bus_track_add_name(sd_bus_track *track, const char *name);
int sd_bus_track_remove_name(sd_bus_track *track, const char *name);

And you are able to query which name is being tracked via:

unsigned sd_bus_track_count(sd_bus_track *track);
const char* sd_bus_track_contains(sd_bus_track *track, const char *names);
const char* sd_bus_track_first(sd_bus_track *track);
const char* sd_bus_track_next(sd_bus_track *track);

So far so good, yeah?

But if you pay attention to the prototype of sd_bus_track_handler_t, you’ll notice that you won’t be able to get the tracked service name when this handler being called.

Which means you simply can’t use it to track more than one service name, because you can’t distinguish which service actually exits.

If I checked all existing usages of sd_bus_track in systemd, they imply that my impression is correct.

So obviously “tracking multiple name” functionality is totally useless.

So here, this is a good example about how this api should looks like: http://doc.qt.io/qt-5/qdbusservicewatcher.html .

For my own use case, I’ll go back to write my own service tracker with other sd-bus api.

Posted in fcitx development, Linux | Tagged , | Leave a comment

RFC: a new solution to Input Method + Keyboard Layout

This is not related to KDE itself, but I’d like to hear some opinion from keyboard layout users, especially from those who use more than one keyboard layout.

Right now I’m designing a new feature for fcitx (for people who doesn’t know it, it’s an input method framework under Linux), currently called “input method group”. The goal of this feature is to solve the conflict between keyboard layout and input method (mostly conceptually) . It can also solve some other problem, but the original goal is about keyboard layout.

Before I introduce the feature, I’d like to talk about the problem itself first.

People need to type their own language with their keyboard. For most latin character based languages, keyboard layout is a good solution to them, because the number of different characters in their language is small enough to be handled by the keyboard (26 * (1..2)). But in CJK world (Chinese, Japanese, Korean), number of characters are so large (especially for Chinese, number of characters in Chinese is over thousand) that each character can’t be simply mapped to a key on the keyboard. So people invent input method, which basically maps a sequence of key to a limited number of characters and people can select from it.

But if we re-think about the keyboard layout itself, it can actually be considered as a very simple kind of input methods. The only difference is that the mappings from “keys” to “characters” in keyboard layout is much simpler than those in CJK input method. And that’s why keyboard layouts are handled as input method in modern OS, like windows and mac OSX, and ibus/fcitx nowadays.

It looks so far so good, until you remember that keyboard are not only used to type text. Suppose you want to type French and German, and you add them as your input methods. But hey, French layout is azerty and German is qwertz. Your favorite “Ctrl+Z” for undo is at the different position on the keyboard! If you add Chinese pinyin into consideration, it will be even more messed up. Not to mention if you want to use Dovrak layout with Pinyin and but pinyin is forced you to US layout on Windows.

Though keyboard layout can be considered as an input method, it’s actually a mapping from physical keys to virtual keys (and to characters). And regular CJK input method is a mapping from virtual keys to characters. So they should be able to composed arbitrary to serve user’s own need (e.g. Pinyin + Dovrak).

And we previously had a user provided one of his scenerio:

* Kain(fake name, you know) has two keyboards. One is laptop built-in with US layout, which he will use at  home. Another is a usb keyboard, but it’s in fr layout (key printing).
* He usually use Pinyin and Mozc to type Chinese and Japanese.

He want to automatically switch layout when he’s using different keyboard. While X/wayland doesn’t provide “per physical keyboard” layout (I don’t think “real” per physical keyboard layout is useful though, since you’ll still only use one physical keyboard at a time.), I’d like to support such use case and that’s why I invent the concept of “input method group”.

Basically a input method group contains a list of input methods, and has a layout. This layout will be the actual “system” layout. It affects all the hotkey bindings for your desktop. And for Kain’s use case

His configuration will look like this:
* Default group (us layout):
* Keyboard (default), Pinyin, Mozc
*
* Alternative group (fr layout):
* Input methods are the same as default.

And we can listen to udev event, once the keyboard is plugged in, automatically switch to group fr and he can happily type with fr layout.

For regular CJK user, they can stick to one group. For regular keyboard layout users who want old fashion keyboard layout like setup, they can use different groups with single “keyboard” input method.

And I’d also like to support multiple layout based input method in same group. With help with xkbcommon, this can be actually done. So you can have “Keyboard (US English)” and “Keyboard (Arabic)” in same group, but your system layout will always be US layout even you’re using “Keyboard (Arabic)” to type.

And I think it can also help users who only use some specific language at work and another language at home. And I think is fit quite well with KDE’s activities, e.g. bind different activities with specific input method group. After all, if you want 3 different input methods, but only two of them at a time, it would be easier to switch input method between 2 instead of 3.

What do you think of it? I’d like to make this feature supports the needs of both keyboard layout users and input method users. Do you have any other use case related that you want to share?

Posted in KDE, Linux | Tagged | 11 Comments

Use Jolla Phone to share Wifi via USB

Recently I got a new Surface Pro 4, and starts to use it as my main laptop. I’m glad that it can work with Linux quite well. But it does have some issue that I can’t live with: wifi will stop working after hours randomly.

Though someone points a workaround to me on reddit, but it does not work for me. Fortunately, I was able to just use my usb ethernet at that time. But recently, I moved my seat at home to a place where I couldn’t reach the ethernet cable, so I has been forced to use wifi since then.

Luckily, I found a thread that indicated that I can make my Jolla phone to share the internet via USB. To make it short, one just need to execute

pkcon install usb-moded-connection-sharing-android-config

with developer account and restart the phone.

But later I found that it only works with Cellular network but not with wifi. I digged into the related usb-moded code to confirm that. The implementation explicitly disables wifi and enables cellular network for sharing.

But this is not the end of the story. I found I can still manually enable wifi after select Internet sharing as usb mode. But the network itself doesn’t work, because the implementation only adds the masquerade iptables rule for the cellular network. So I just tried to add my iptables rule manually via:

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

And it works!

Then I created an expect(1) script to ssh to phone and execute the iptables command automatically, so now I can happily use Jolla to connect the wifi network for me, just like using a wifi dongle. I still need to configure the dns server manually via networkmanager for my local connection because the dns server pushed by dhcp server is for cellular network, but that’s good enough since I can even use google’s public dns server blindly if I don’t are too much about the dns speed.

This iptables rule also seems to be persistent if you don’t restart the phone, so I’m also considering to add it when the phone boots. For now I’m happy with my current solution.

Posted in Linux | Tagged , , , | Leave a comment

同一台电脑的 Linux/Windows 系统的蓝牙连接同一个设备

http://ubuntuforums.org/showthread.php?t=1479056

方法从这里找到的,不过在这里有少许区别。

情况是这样的,如果你有同一个蓝牙设备,想要同时在 Windows / Linux (或者多个 Linux 系统)使用,你会发现在一个系统下配对之后,在另一个系统连接时会连接失败。因为蓝牙在配对后会生成一个 key,而这个 key 在不同的系统下并没有共享。

那么问题就是怎么修改/读取这个 key 了。

Windows 下,key 保存在注册表中。我没有尝试,但是上面的链接提到即使管理员模式也无权访问?所以改为从 Linux 下读取注册表的方式访问Key 。从 Linux 下面也可以使用方便的工具 chntpw 读取。首先备份一个 Windows\System32\config\SYSTEM 文件,然后使用 chntpw 即可读取。我的 key 在 \ControlSet001\Services\BTHPORT\Parameters\Keys\[Bluetooth adapter MAC address]\[Bluetooth device MAC address] 下。

在执行 chntpw -e [SYSTEM 文件的路径] 之后,可以使用 cd / ls 像访问文件一样访问。在到了最终的目录之后,使用 hex [key 名称] 查看对应的 key 的 16 进制。

在 bluez 5 的环境下,配对后会在 /var/lib/bluetooth/[Bluetooth adapter MAC address]/[Bluetooth device MAC address]/info 这个文件内写入设备的信息,格式就是普通的 ini。找到 [LinkKey] 下面的 Key= 行,填入对应的 16 进制 Key (无空格)即可。

总结一下流程:

  1. 在 Linux 下先配对,生成对应的 info 文件。
  2. 然后在 Windows 下重新配对,产生新的 Key,并存在了注册表中。
  3. 再到 Linux 修改对应文件。
Posted in Linux | Tagged , | 1 Comment