Is there any efficient way to differentiate between "passé composé" and "imparfait"? In the current state of my knowledge , I am able to differentiate only for certain cases , e.g I know descriptions of weather use "imparfait" , habitual actions use "imparfait", long timing uses "imparfait" etc., but for some questions, I am still not able to know which tenses to use; for example,
1) Nous jouions aux échecs depuis un bon moment. why do we use "jouions" instead of "avons joué" ?
2) J.K Rowling a écrit Harry Potter. Why is it we use "a écrit" instead of écrivait ? Isn't this continuous and don't we know the exact "moment" when she wrote the text ?
I need some suggestions of study links or anything that will help me in understanding when to use "passé composé" or "imparfait".